I have two pages that need to submit to the database; a user registration page and a tire-input page. The user registration page works. The tire-input page does not. The tire page will show the alert inside the "submitClick()" but doesn't input anything into the database. If there is anymore information that you need, let me know. Thanks in advance.
I've tried working with the rules:
Current (letting the user-registration work, but not the tire-input)
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
}
Not letting anything work:
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
},
"Tires": {
".read": true,
".write": true
}
}
}
HTML code (tire):
<?php
require ($_SERVER['DOCUMENT_ROOT'] . '/Emily-Projects/variables.php');
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../inc/styles/css.css">
</head>
<body>
<div class="container">
<div class="content" style="background-color: white;">
<div id="heading">
<h1>Add A Tire<h1>
</div>
<form>
<div id="1" class="form-sections">
<div class="input-div">
<label for="width" class="label">Width</label>
<select name="width" id="width" type="select" class="input">
<option value="">---</option>
<?php foreach ($tireWidths as $width) {?>
<option value="<?php echo $width;?>"><?php echo $width;?></option>
<?php } ?>
</select></div>
<div class="easy-div">
<div>
<?php foreach ($width100s as $width){ ?>
<z data-role="button" data-val="<?php echo $width;?>" class="width-sm"><?php echo $width?></z>
<?php } ?>
</div>
<div>
<?php foreach ($width200s as $width){ ?>
<z data-role="button" data-val="<?php echo $width;?>" class="width-sm"><?php echo $width?></z>
<?php } ?>
</div>
<div>
<?php foreach ($width300s as $width){ ?>
<z data-role="button" data-val="<?php echo $width;?>" class="width-sm"><?php echo $width?></z>
<?php } ?>
</div>
</div>
</div> <!-- closing div#1-->
<div id="2" class="form-sections">
<div class="input-div">
<label for="aspect" class="label">Aspect Ratio</label>
<select class="input" name="aspect" id="aspect">
<option value="">---</option>
<?php foreach ($aspects as $aspect) {?>
<option value="<?php echo $aspect;?>"><?php echo $aspect;?></option>
<?php }?>
</select>
</div>
<div class="easy-div">
<div>
<?php foreach ($aspectsTop as $a){ ?>
<z data-role="button" data-val="<?php echo $a;?>" class="aspectVal"><?php echo $a;?></z>
<?php } ?>
</div>
<div>
<?php foreach ($aspectsBottom as $a){ ?>
<z data-role="button" data-val="<?php echo $a;?>" class="aspectVal"><?php echo $a;?></z>
<?php } ?>
</div>
</div>
</div> <!-- closing div#2-->
<div id="3" class="form-sections">
<div class="input-div">
<label class="label" for="rim">Rim Diameter</label>
<select id="rim" name="rim" class="input">
<option value="">---</option>
<?php foreach ($rimDiameter as $rim){ ?>
<option value="<?php echo $rim;?>"><?php echo $rim;?></option>
<?php } ?>
</select>
</div>
<div class="easy-div">
<div>
<?php foreach ($rimDiaTop as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="rimVal"><?php echo $r;?></z>
<?php }?>
</div>
<div>
<?php foreach ($rimDiaBottom as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="rimVal"><?php echo $r;?></z>
<?php }?>
</div>
</div>
</div> <!-- closing div#3-->
<div id="4" class="form-sections">
<div class="input-div">
<label class="label" for="manufacturer">Manufacturer</label>
<select class="input" name="manufacturer" id="manufacturer">
<option value="">---</option>
<?php foreach ($manufacturers as $m) { ?>
<option value="<?php echo $m;?>"><?php echo $m;?></option>
<?php } ?>
</select>
</div>
<div class="easy-div">
<div id="manu-group-one">
<?php foreach ($manufacturersOne as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="manVal"><?php echo $r;?></z>
<?php }?>
</div>
<div id="manu-group-two">
<?php foreach ($manufacturersTwo as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="manVal"><?php echo $r;?></z>
<?php }?>
</div>
<div id="manu-group-three">
<?php foreach ($manufacturersThree as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="manVal"><?php echo $r;?></z>
<?php }?>
</div>
<div id="manu-group-four">
<?php foreach ($manufacturersFour as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="manVal"><?php echo $r;?></z>
<?php }?>
</div>
<div id="manu-group-five">
<?php foreach ($manufacturersFive as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="manVal"><?php echo $r;?></z>
<?php }?>
</div>
<div id="manu-group-six">
<?php foreach ($manufacturersSix as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="manVal"><?php echo $r;?></z>
<?php }?>
</div>
</div>
</div> <!-- closing div#4-->
<div id="5" class="form-sections">
<div id="5a" class="inner-B"><div class="input-div"><label class="label" for="model">Model</label>
<select id="model" name="model" class="input">
<option value="">---</option>
<option value="test">Test</option>
</select>
</div>
<div class="easy-div">EASY BUTTONS</div>
</div><!--closing A -->
<div id="5B" class="inner-A"><label class="label" for="weight">Shipping Weight</label><input type="text" name="weight" id="weight" class="input"></div><!--closing B -->
</div> <!-- closing div#5-->
<div id="6" class="form-sections">
<div id="6A" class="inner-C">
<div class="input-div">
<label class="label" for="trim">Trim</label>
<select name="trim" id="trim" class="input" >
<option value="">---</option>
<option value="test">Test</option>
</select>
</div>
<div class="easy-div">EASY BUTTONS</div>
</div><!--closing A -->
<div id="6B" class="inner-D">
<label class="label" for="cost">Tire Cost</label>
<input name="cost" id="cost" class="input">
</div><!--closing B -->
<div id="6C" class="inner-E">PICTURES</div><!--closing C -->
</div> <!-- closing div#6-->
<div id="7" class="form-sections">
<div id="7A" class="inner-D">
<div class="label">Run Flat?</div>
<div class="input"><input type="radio" name="runflat" value="yes"> Yes <input type="radio" name="runflat" value="no"> No </div>
</div><!--closing A -->
<div id="7B" class="inner-F">
<div class="label">Tread Depth</div>
<div class="input">
<input type="text" name="tread" id="tread" ><br><br>
<?php for($i=1; $i<11; $i++){ ?>
<z data-role="button" > <?php echo $i;?></z>
<?php } ?>
<?php for($i=11; $i<21; $i++){ ?>
<z data-role="button" > <?php echo $i;?></z>
<?php } ?> <z data-role="button" >.25 </z>
<z data-role="button" >.5</z>
<z data-role="button" >.75</z>
</div>
</div><!--closing B -->
<div id="7C" class="inner-F"><div class="label">DOT Date</div><div class="input">INPUT</div></div><!--closing C -->
<div id="7D" class="inner-F"><label class="label" for="patches">Number of Patches</label>
<div class="input"><?php for($i=0;$i<5;$i++){?>
<z data-role="button" ><?php echo $i;?></z>
<?php
}?></div></div> <!--closing D-->
</div> <!-- closing div#7-->
<div id="8" class="form-sections">
<div id="8A" class="inner-G"><div class="label">Retail Price</div>
<input type="text" id="retailPrice" name="retailPrice" class="input">
</div>
<div id="8B" class="inner-G"><div class="label">C.U.T. Share</div><div class="input">- $4.99 </div></div>
<div id="8C" class="inner-G"><div class="label">C.C. Fee</div><div class="input"><?php echo $ccfee;?></div></div>
<div id="8D" class="inner-G">Not Applicable</div>
<div id="8E" class="inner-G"><div class="label">Shipping Est.</div><div class="input"><?php echo $shipEst;?></div></div>
<div id="8F" class="inner-G"><div class="label">My Pay Out</div><div class="input"><?php echo $payOutRetail;?></div></div>
<div id="8G" class="inner-G"><div class="label">Tire NOT listed on Cheapest Used Tires</div><div class="input">INPUT</div></div>
</div> <!-- closing div#8-->
<div id="9" class="form-sections">
<div id="9A" class="inner-G"><div class="label">Wholesale Price</div>
<input type="text" id="retailPrice" name="retailPrice" class="input"></div>
<div id="9B" class="inner-G"><div class="label">C.U.T. Share</div><div class="input">- $4.99</div></div>
<div id="9C" class="inner-G"><div class="label">C.C. Fee</div><div class="input"><?php echo $ccfee;?></div></div>
<div id="9D" class="inner-G"><div class="label">Buyer's Bucks</div><div class="input">- $3.00</div></div>
<div id="9E" class="inner-G"><div class="label">Shipping Est.</div><div class="input"><?php echo $shipEst;?></div></div>
<div id="9F" class="inner-G"><div class="label">My Pay Out</div><div class="input"><?php echo $payOutWS;?></div></div>
<div id="9G" class="inner-G"><div class="label">Wholesale ONLY</div><div class="input">INPUT</div></div>
</div><!--closing div#9-->
<input type="submit" id="submit" onclick="submitClick()"value="Add This Tire">
</form>
</div>
</div> <!-- closing container -->
<script src="https://www.gstatic.com/firebasejs/4.6.2/firebase.js"></script>
<script src="/Emily-Projects/new-add-a-tire.js"></script>
</body>
</html>
Tire JS:
//File: new-add-a-tire.js
// Initialize Firebase
var config = {
apiKey: "AIzaSyCLpexd_9jOLjwcraume8RDXqag8mUSyMY",
authDomain: "funoto-a67ec.firebaseapp.com",
databaseURL: "https://funoto-a67ec.firebaseio.com",
projectId: "funoto-a67ec",
storageBucket: "funoto-a67ec.appspot.com",
messagingSenderId: "270438905275"
};
firebase.initializeApp(config);
//Add a Tire to Firbase
var width = document.getElementById("width");
var aspect = document.getElementById("aspect");
var rim = document.getElementById("rim");
var manufacturer = document.getElementById("manufacturer");
var submitBtn = document.getElementById("submit");
//Function: submitClick();
function submitClick(){
window.alert("Works");
var firebaseRef = firebase.database().ref();
firebaseRef.child("Tires").set("some value");
}
I am following the official doc try this
function submitClick(){
window.alert("Works");
var firebaseRef = firebase.database();
firebaseRef.ref("Tires").set({tire: "round"});
}
Related
I have a page with two tabs and each tab can be showed If we clicked on a link inside a page.
Is there anyway to get to my tab and show tab's content ?
Here is my site url https://www.behealthy.asia/cp/
Here is the first tab https://www.behealthy.asia/cp/#regularuser
Here is the second tab https://www.behealthy.asia/cp/#company
and this is my code.
<div class="<?php echo esc_attr($getClasses); ?>">
<div class="tg-registerarea tg-haslayout">
<?php if (!empty($atts['title']))
{ ?>
<div class="tg-loginarea">
<div class="tg-bordertitle">
<h3><?php echo esc_attr($atts['title']); ?></h3>
</div>
</div>
<?php
} ?>
<fieldset>
<ul class="tg-tabnav" role="tablist">
<li role="presentation" class="active">
<a href="#regularuser" data-toggle="tab">
<span class="lnr lnr-user"></span>
<div class="tg-navcontent">
<h3><?php esc_html_e('Regular Single User', 'listingo_core'); ?></h3>
<span><?php esc_html_e('Register As Service Seeker', 'listingo_core'); ?></span>
</div>
</a>
</li>
<li role="presentation">
<a href="#company" data-toggle="tab">
<span class="lnr lnr-briefcase"></span>
<div class="tg-navcontent">
<h3><?php esc_html_e('Company / Professional', 'listingo_core'); ?></h3>
<span><?php esc_html_e('Register As Service Provider', 'listingo_core'); ?></span>
</div>
</a>
</li>
</ul>
<div class="tg-themetabcontent tab-content">
<div class="tab-pane active fade in" id="regularuser">
<form action="#" method="post" class="seeker-register do-registration-form">
<div class="form-group">
<div class="tg-registeras">
<span><?php esc_html_e('Already have an account? Please login', 'listingo_core'); ?></span>
</div>
</div>
<div class="form-group">
<input type="text" name="register[username]" class="form-control" placeholder="<?php esc_html_e('User Name, eg alex', 'listingo_core'); ?>">
</div>
<?php if (apply_filters('listingo_dev_manage_fields', 'true', 'user_nicename') === 'true')
{ ?>
<div class="form-group">
<input type="text" name="register[user_nicename]" class="form-control" placeholder="<?php esc_html_e('Nicename eg : alex', 'listingo_core'); ?>">
<?php do_action('listingo_get_tooltip', 'element', 'nicename'); ?>
</div>
<?php
} ?>
<?php if (apply_filters('listingo_dev_manage_fields', 'true', 'first_name') === 'true')
{ ?>
<div class="form-group">
<input type="text" name="register[first_name]" class="form-control" placeholder="<?php esc_html_e('First Name', 'listingo_core'); ?>">
</div>
<?php
} ?>
<?php if (apply_filters('listingo_dev_manage_fields', 'true', 'last_name') === 'true')
{ ?>
<div class="form-group">
<input type="text" name="register[last_name]" class="form-control" placeholder="<?php esc_html_e('Last Name', 'listingo_core'); ?>">
</div>
<?php
} ?>
<?php if (apply_filters('listingo_dev_manage_fields', 'true', 'gender') === 'true')
{ ?>
<div class="form-group">
<span class="tg-select">
<select name="register[gender]">
<option value=""><?php esc_html_e('Gender', 'listingo_core'); ?></option>
<option value="male"><?php esc_html_e('Male', 'listingo_core'); ?></option>
<option value="female"><?php esc_html_e('Female', 'listingo_core'); ?></option>
</select>
</span>
</div>
<?php
} ?>
<?php if (apply_filters('listingo_dev_manage_fields', 'true', 'phone') === 'true')
{ ?>
<div class="form-group">
<input type="text" name="register[phone]" class="form-control" placeholder="<?php esc_html_e('Phone', 'listingo_core'); ?>">
<?php do_action('listingo_get_tooltip', 'element', 'phone'); ?>
</div>
<?php
} ?>
<div class="form-group">
<input type="email" name="register[email]" class="form-control" placeholder="<?php esc_html_e('Email', 'listingo_core'); ?>">
</div>
<div class="form-group">
<input type="password" name="register[password]" class="form-control" placeholder="<?php esc_html_e('Password', 'listingo_core'); ?>">
</div>
<div class="form-group">
<input type="password" name="register[confirm_password]" class="form-control" placeholder="<?php esc_html_e('Retype Password', 'listingo_core'); ?>">
</div>
<?php do_action('listingo_registration_customer_extra_fields'); ?>
<div class="form-group term-group">
<?php
if (isset($captcha_settings) && $captcha_settings === 'enable')
{
?>
<div class="domain-captcha">
<div id="recaptcha_signup"></div>
</div>
<?php
} ?>
<div class="tg-checkbox">
<input name="terms" type="hidden" value="0" />
<input name="terms" type="checkbox" id="terms">
<label for="terms">
<?php if (!empty($terms_link))
{ ?>
<?php esc_html_e('I have read the', 'listingo_core'); ?> <a target="_blank" href="<?php echo esc_url($terms_link); ?>"><?php esc_html_e('Terms & Conditions', 'listingo_core'); ?></a> <?php esc_html_e('and accept them', 'listingo_core'); ?>
<?php
}
else
{ ?>
<?php
echo "ฉันยอมรับในเงื่อนไขและข้อกำหนดทุกประการ";
?>
<?php
} ?>
คลิกเพื่ออ่านเงื่อนไขและข้อกำหนด
</label>
<input type="hidden" name="register[account]" value="seeker">
<?php wp_nonce_field('register_seeker_request', 'register_seeker_request'); ?>
<button class="tg-btn do-regiter-me" type="submit"><?php esc_html_e('Register Now', 'listingo_core'); ?></button>
</div>
</div>
</form>
</div>
<div class="tab-pane fade in" id="company">
<form action="#" method="post" class="do-registration-form">
<div class="form-group">
<div class="tg-registeras">
<span><?php esc_html_e('Register As', 'listingo_core'); ?>:</span>
<div class="tg-radio">
<input type="radio" class="register_type" value="business" id="business" name="register[type]" checked>
<label for="business"><?php esc_html_e('Business', 'listingo_core'); ?></label>
</div>
<div class="tg-radio">
<input type="radio" class="register_type" value="professional" id="professional" name="register[type]">
<label for="professional"><?php esc_html_e('professional', 'listingo_core'); ?></label>
</div>
</div>
</div>
<div class="form-group">
<span class="tg-select">
<select name="register[category]" class="sp-category">
<option value=""><?php esc_html_e('Select Category', 'listingo_core'); ?></option>
<?php listingo_get_categories('', 'sp_categories'); ?>
</select>
</span>
</div>
Note that there is two tab, #regularuser and #company
I made a loop using foreach, to show a list of products. Then I made a modal to edit each product. I need to get the value of product dimension and I'll make a dependent drop down between 'job drop down' and 'supply drop down'. At the moment, I can't continue it with Ajax because I got a problem at the first step to get value of dimension. In this code below I tried to get 'length' value of each product through javascript. But it returns the same value, it always is the value of the first product, even if I click on the 2nd, 3rd, 4th of product in the list.
<div class="table-responsive">
<table class="table table-hover" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>Product</th>
<th>Supplier</th>
<th>Dimension</th>
<th>Edit</th>
</tr>
</thead>
<tbody>
<?php
$pcs_1 = 0;
$meter_1 = 0;
foreach ($stock as $s) { ?>
<tr>
<td class="small">
<?php echo $s->cat . ' - ' . $s->prod ?>
</td>
<td class="small">
<?php echo $s->spl ?>
</td>
<td class="small">
<?php echo $s->length . ' x ' . $s->width . ' x ' . $s->height . ' x ' . $s->diameter ?>
</td>
<td>
<a type="button" data-toggle="modal" class="btn btn-small" data-target="#modal_edit<?php echo $s->id ?>"><i class="fas fa-edit"></i></a>
<!--MODAL-->
<div class="modal fade" id="modal_edit<?php echo $s->id ?>" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" method="post" action="<?php echo site_url('admin/Stock/edit/') ?>">
<div class="modal-header">
<h5 class="modal-title" id="labelModal">EDIT STOCK</h5>
</div>
<div class="modal-body">
<input type="hidden" id="length_product" class="length_product" value="<?php echo $s->length ?>" />
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-sm-3">
<div class="form-group">
<?php echo form_label('JOB') ?>
</div>
</div>
<div class="col-sm-9">
<div class="form-group">
<select name="ref" id="ref" class="form-control" required onchange="GetData()">
<option value="">-- Select Job --</option>
<?php foreach ($job as $j) : ?>
<option value="<?php echo $j->id; ?>"><?php echo $j->id ?> - <?php echo $j->cust ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<div class="form-group">
<?php echo form_label('Supply') ?>
</div>
</div>
<div class="col-sm-9">
<select name="supply" id="supply" class="form-control" required>
<option value="">--Select Supply--</option>
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-warning submitBtn">edit</button>
</div>
</form>
</div>
</div>
</div> <!-- modal -->
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
Here is the javascript :
<script type="text/javascript">
function GetData() {
var length_product = $("#length_product").val();
alert(length_product);
}
</script>
The list works well, but I don't know how to get the detail of each list on javascript (passing multiple values from 'modal inside the list' to 'Javascript').
for me it looks like that you are always getting value of
<input type="hidden" id="length_product" class="length_product" value="<?php echo $s->length ?>" />
rather than option from the select element.
Try the following:
$('#ref').on('change', function(event) {
event.preventDefault();
var length_product = $(this).val();
alert(length_product);
});
and for the PHP and HTML:
<div class="form-group">
<select name="ref" id="ref" class="form-control" required>
<option value="">-- Select Job --</option>
<?php foreach ($job as $j) { ?>
<option value="<?php echo $j["id"]; ?>"><?php echo $j["id"]; ?>-<?php echo $j["cust"]; ?></option>
<?php
}
?>
</select>
</div>
Hope this helps!
Good day,
I've been trying to get all the dynamic select box but it always returning the first color.
For example i have 1 default set of color, but then i click the Add More it adds another set of color but when i posting it in my controller it always return the first color and disregard the other added set of color. This is the sample image set of color
Can someone help me on this? I've been stucked for 4days now.
Here's my view code:
<div class="form-content">
<div class="row">
<div class="col-md-12">
<p><button type="button" id="btnAdd" class="btn btn-primary">Add Color</button></p>
<br/>
</div>
</div>
<div class="row group">
<div class="col-md-5">
<div class="form-group">
<label></label>
<select name="color1[]" id="color1" class="form-control" >
<option value="" > Color 1</option>
<?php foreach($colors as $color): ?>
<option value="<?php echo $color['colorID']; ?>">
<?php echo $color['colorDesc']; ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-md-5">
<div class="form-group">
<label></label>
<select name="color2[]" id="color2" class="form-control" >
<option value="" > Color 2</option>
<?php foreach($colors as $color): ?>
<option value="<?php echo $color['colorID']; ?>">
<?php echo $color['colorDesc']; ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<button type="button" class="btn btn-danger btnRemove">X</button>
</div>
</div>
</div>
</div>
And here's the script
<script type="text/javascript">
$(".form-content").multifield({
section: ".group",
btnAdd:"#btnAdd",
btnRemove:".btnRemove",
});
</script>
And here's my Controller
$color1 = $this->input->post('color1');
$color2 = $this->input->post('color2');
for($i = 0; $i < count($color1); ++$i) {
echo $make = $color1[$i];
}
I just started using Codeigniter newbie in short. Please help me to fix this. Thanks in advance.
Try this (I not tested):
HTML:
<div class="form-content">
<div class="row">
<div class="col-md-12">
<p>
<button type="button" id="btnAdd" class="btn btn-primary">Add Color</button>
</p>
<br/>
</div>
</div>
<?php $count=0 ; if($this->input->post('color1')) $count = count($this->input->post('color1')); for($i=0;$i<$count,$i++):?>
<div class="row group">
<div class="col-md-5">
<div class="form-group">
<label></label>
<select name="color1[<?php echo $i;?>]" id="color1" class="form-control" <?php set_select( 'color1['.$i. ']',$color[ 'colorID']);?>>
<option value=""> Color 1</option>
<?php foreach($colors as $color): ?>
<option value="<?php echo $color['colorID']; ?>">
<?php echo $color[ 'colorDesc']; ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-md-5">
<div class="form-group">
<label></label>
<select name="color2[<?php echo $i;?>]" id="color2" class="form-control">
<option value=""> Color 2</option>
<?php foreach($colors as $color): ?>
<option value="<?php echo $color['colorID']; ?>" <?php set_select( 'color2['.$i. ']',$color[ 'colorID']);?>>
<?php echo $color[ 'colorDesc']; ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<button type="button" class="btn btn-danger btnRemove">X</button>
</div>
</div>
</div>
<?php endfor;?>
</div>
in controller (you can also add validation):
...
if($this->input->post('color1')) {
$result = array();
$count = count($this->input->post('color1'));
for($i=0;$i<$count;$i++) {
if($this->input->post('color1['.$i.']') && $this->input->post('color2['.$i.']')) {
$result[$i] = ['color1'=>$this->input->post('color1['.$i.']'),'color2'=>$this->input->post('color2['.$i.']')];
}
}
print_r($result);
}
...
I'm working in OpenCart MVC and I have a page that has a main form called campaign. there is a secondary form called components. the component form allows for multiple instances of itself(click add another component shows). The idea is that a campaign can have infinite components and on submit the campaign info will be written to the campaign table and the component info will be written to the component table. well that is not happening. currently when i fill out both forms and submit. the info for campaign form is written to the table. however in the component table a new record is made but its all blank. Why are the values not being added? Furthermore, additional components seem to not get written at all. so if you start a campaign and add three components then submit only one new(blank) record will be written in components.
MODEL:
public function addCampaign($data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "campaigns SET campaign_name = '" . $this->db->escape($data['campaign_name']) . "', campaign_giving_goal = '" . (float)$data['campaign_giving_goal']
. "', code = '" . $this->db->escape($data['code']) . "', campaign_active = '" . $this->db->escape($data['campaign_active']) . "', campaign_giving_count_goal = '" . (float)$data['campaign_giving_count_goal']
. "', campaign_owner = '" . $this->db->escape($data['campaign_owner']). "', date_beginning = '" . $this->db->escape($data['date_beginning']). "', date_ending = '" . $this->db->escape($data['date_ending']). "'");
$this->cache->delete('campaign');
return $campaign_id;
}
public function addComponent($data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "campaign_components SET component_name = '" . $this->db->escape($data['component_name']) . "', component_date = '" . $data['component_date']
. "', component_owner = '" . $this->db->escape($data['component_owner']). "', campaign_code = '" . $this->db->escape($data['campaign_code']) . "'");
$this->cache->delete('campaign');
return $campaign_id;
}
CONTROLLER:
public function add() {
$this->load->language('campaigns/campaign');
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('campaigns/campaign');
if (($this->request->server['REQUEST_METHOD'] == 'POST')) {
$this->model_campaigns_campaign->addCampaign($this->request->post);
$this->model_campaigns_campaign->addComponent($this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$url = '';
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->response->redirect($this->url->link('campaigns/campaign', 'token=' . $this->session->data['token'] . $url, true));
}
$this->getForm();
}
VIEW:
<?php echo $header; ?><?php echo $column_left; ?>
<div id="content">
<div class="page-header">
<div class="container-fluid">
<div class="pull-right">
<button type="submit" form="form-campaign" action="<?php echo $action; ?>" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary" onclick="submitForms()"><i class="fa fa-save"></i></button>
<i class="fa fa-reply"></i>
</div>
<h1><?php echo $heading_title; ?></h1>
<ul class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li><?php echo $breadcrumb['text']; ?></li>
<?php } ?>
</ul>
</div>
</div>
<div class="container-fluid">
<?php if ($error_warning) { ?>
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
<button type="button" class="close" data-dismiss="alert">×</button>
</div>
<?php } ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $text_form; ?></h3>
</div>
<div class="panel-body">
<form method="post" action="<?php echo $action; ?>" enctype="multipart/form-data" id="form-campaign" class="form-horizontal">
<div class="tab-content">
<div class="tab-pane active" id="tab-general">
<?php foreach ($languages as $language) { ?>
<div class="tab-pane" id="language<?php echo $language['language_id']; ?>">
<div class="form-group">
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" for="input-campaign-name"><?php echo $entry_name; ?></label>
<input type="text" name="campaign_name" placeholder="<?php echo $entry_name; ?>" id="input-campaign-name" class="form-control" value="<?php echo $campaign_name; ?>" />
<?php if (isset($error_name[$language['language_id']])) { ?>
<div class="text-danger"><?php echo $error_name[$language['language_id']]; ?></div>
<?php } ?>
</div>
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" ><?php echo $entry_owner; ?></label>
<select name="campaign_owner" id="campaign_owner" value="<?php echo $campaign_owner; ?>">
<?php foreach ($users as $user) { ?>
<option value="<?php echo $user['username']; ?>"><?php echo $user['username']; ?></option>
<?php } ?>
</select>
</div>
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" for="input-campaign-goal"><?php echo $entry_goal; ?></label>
<input type="text" name="campaign_giving_goal" placeholder="<?php echo $entry_goal; ?>" id="input-campaign-goal" class="form-control" value="<?php echo $campaign_giving_goal; ?>" />
<?php if (isset($error_name[$language['language_id']])) { ?>
<div class="text-danger"><?php echo $error_name[$language['language_id']]; ?></div>
<?php } ?>
</div>
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" for="input-campaign-goal"><?php echo $entry_goal_count; ?></label>
<input type="text" name="campaign_giving_count_goal" placeholder="<?php echo $entry_goal_count; ?>" id="input-campaign-goal-count" class="form-control" value="<?php echo $campaign_giving_count_goal; ?>" />
<?php if (isset($error_name[$language['language_id']])) { ?>
<div class="text-danger"><?php echo $error_name[$language['language_id']]; ?></div>
<?php } ?>
</div>
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" for="input-date-beginning"><?php echo $entry_campaign_start_date; ?></label>
<div class="input-group date required">
<input type="text" name="date_beginning" placeholder="<?php echo $entry_date; ?>" data-date-format="YYYY-MM-DD" id="input-date-beginning" class="form-control" value="<?php echo $date_beginning; ?>" readonly />
<span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button>
</span>
</div>
<?php if (isset($error_date_starting)) { ?>
<label class="text-danger"><?php echo $error_date_starting; ?></label>
<?php } ?>
</div>
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" for="input-date-ending"><?php echo $entry_campaign_end_date; ?></label>
<div class="input-group date required">
<input type="text" name="date_ending" placeholder="<?php echo $entry_campaign_end_date; ?>" data-date-format="YYYY-MM-DD" id="input-date-ending" class="form-control" value="<?php echo $date_ending; ?>" readonly />
<span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button>
</span>
</div>
<?php if (isset($error_date_starting)) { ?>
<label class="text-danger"><?php echo $error_date_starting; ?></label>
<?php } ?>
</div>
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" for="input-code"><?php echo $entry_code; ?></label>
<div class="input-code required">
<input type="text" name="code" value="<?php echo $code; ?>" placeholder="<?php echo $code; ?>" id="input-code" class="form-control" readonly />
</div>
<?php if (isset($error_date_starting)) { ?>
<label class="text-danger"><?php echo $error_code; ?></label>
<?php } ?>
</div>
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" for="input-active"><?php echo $entry_active; ?></label>
<select name="campaign_active" id="input-"active" class="form-control">
<option value="*"><?php echo $text_active; ?></option>
<?php if ($filter_campaign_active) { ?>
<option value="1" selected="selected"><?php echo $text_yes; ?></option>
<?php } else { ?>
<option value="1"><?php echo $text_yes; ?></option>
<?php } ?>
<?php if (!$filter_campaign_active && !is_null($filter_campaign_active)) { ?>
<option value="0" selected="selected"><?php echo $text_no; ?></option>
<?php } else { ?>
<option value="0"><?php echo $text_no; ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
</form>
</div>
</div>
</div>
<button class="btn btn-primary" id="launch"><?php echo $text_add_component ?></button>
<div class="wrapper">
<div class="panel panel-default" id="add-components">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $text_add_component; ?></h3>
</div>
<div class="panel-body" id="addon">
<form method="post" enctype="multipart/form-data" id="form-components" class="form-horizontal" action="<?php echo $action; ?>">
<div class="tab-content">
<div class="tab-pane active" id="tab-general">
<?php foreach ($languages as $language) { ?>
<div class="tab-pane" id="language<?php echo $language['language_id']; ?>">
<div class="form-group required">
<div class= "row">
<div class="col-sm-8 col-sm-push-1 form-group required" >
<label for="input-name<?php echo $language['language_id']; ?>"><?php echo $entry_name; ?></label>
<input type="text" name="component_name" placeholder="<?php echo $entry_name; ?>" id="input-name<?php echo $language['language_id']; ?>" class="form-control" />
<?php if (isset($error_name[$language['language_id']])) { ?>
<div class="text-danger"><?php echo $error_name[$language['language_id']]; ?></div>
<?php } ?>
</div>
<div class="col-sm-2 col-sm-push-1 form-group required">
<div class="campaign-group form-group">
<div class="dropdown">
<button class="btn btn-primary pull-left dropdown-toggle" type="button" id="button-type" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"><?php echo $text_filter_type;?><span class="caret"></span></button>
<ul class="campaign-form-type dropdown-menu">
<li class="campaign-dropdown-list">Direct Mail</li>
<li class="campaign-dropdown-list">Email</li>
<li class="campaign-dropdown-list">Event</li>
<li class="campaign-dropdown-list">Text Message</li>
<li class="campaign-dropdown-list">Letter</li>
<li class="campaign-dropdown-list">Postcard</li>
</ul>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4 col-sm-push-1 form-group required">
<label class="control-label" for="input-date-beginning"><?php echo $entry_campaign_start_date; ?></label>
<div class="input-group date required">
<input type="text" name="date_beginning" placeholder="<?php echo $entry_date; ?>" data-date-format="YYYY-MM-DD" id="input-date-beginning" class="form-control" />
<span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button>
</span>
</div>
<?php if (isset($error_date_starting)) { ?>
<label class="text-danger"><?php echo $error_date_starting; ?></label>
<?php } ?>
</div>
<div class="col-sm-4 col-sm-push-1 form-group required">
<label class="control-label" ><?php echo $entry_owner; ?></label>
<select name="campaign_owner" id="component_owner">
<?php foreach ($users as $user) { ?>
<option value="<?php echo $user['username']; ?>"><?php echo $user['username']; ?></option>
<?php } ?>
</select>
</div>
<div class="col-sm-5 col-sm-push-1 form-group required">
<!--label class="control-label" for="input-code"><?php echo $entry_code; ?></label-->
<div class="input-code required">
<input type="text" name="code" value="<?php echo $code; ?>" placeholder="<?php echo $code; ?>" id="input-code" class="form-control" readonly />
</div>
<?php if (isset($error_date_starting)) { ?>
<label class="text-danger"><?php echo $error_code; ?></label>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</form>
</div>
</div>
<div class="cancel-save">
<button type="submit" form="form-campaign" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary" onclick="submitForms(0)"><i class="fa fa-save"></i></button>
<i class="fa fa-reply"></i>
</div>
</div>
</div>
<script type="text/javascript" src="view/javascript/summernote/summernote.js"></script>
<link href="view/javascript/summernote/summernote.css" rel="stylesheet" />
<script type="text/javascript" src="view/javascript/summernote/opencart.js"></script>
</script>
<script type="text/javascript"><!--
$('#input-code').on('keyup', function() {
$('#input-example1').val('<?php echo $store; ?>?tracking=' + $('#input-code').val());
$('#input-example2').val('<?php echo $store; ?>index.php?route=common/home&tracking=' + $('#input-code').val());
});
$('#input-code').trigger('keyup');
//--></script>
<script type="text/javascript">
document.getElementById('launch').onclick = function() {
var addOnDiv = document.getElementById('addon');
var container = document.getElementById('add-components')
var clonedNode = addOnDiv.cloneNode(true);
container.appendChild(clonedNode );
}
</script>
<script type="text/javascript"><!--
submitForms = function(){
document.getElementById("form-campaign").submit();
document.getElementById("form-components").submit();
}
</script>
<script type="text/javascript"><!--
$('.date').datetimepicker({
formatDate:'yyyy-mm-dd',
pickTime: false
});
$('.time').datetimepicker({
pickDate: false,
icons: {
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
},
});
$('.datetime').datetimepicker({
pickDate: true,
pickTime: true
});
//--></script>
<script type="text/javascript"><!--
$('#language a:first').tab('show');
$('#option a:first').tab('show');
//--></script></div>
<?php echo $footer; ?>
This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 7 years ago.
Hello i need your help or advice about one of my problem , so the thing is i have a multi language website (2 languages for now) and have a ad posting form witch starts on http://newproject.comli.com/step1.php and goes to a step2 and the problem starts if i change language on a step2 file its gives me an error like : enter image description here
you wont see those errors on a hosting but there will be no result ether .
so basically i am sending a ids from s step1 to a step2 , ids of user selection to display a category witch they select and later to insert to a database ware get those errors as well if i try to change a language after insert ( i mean i got them inserted into database and then if i change a language its gives me a tons of error it could be moved to a another page if you are trying to change language or just another way to avoid those errors ) the insertions page is ready but i didt create a table for it on my hosting so it wont work there
this is my pages code just to be more understandable what i am talking about and ware is the problem :
step1.php
<?php
include_once 'common.php';
?>
<!DOCTYPE html>
<html lang="<?php echo $lang['LANG']; ?>">
<head>
<title><?php echo $lang['PAGE_TITLE']; ?></title>
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="js/ism-2.1.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
$(".level2 > li").hide();
$(".level1 > li").on("click", function() {
$(this).siblings().css("background-color", "transparent");
$(this).css("background-color", "#f1f1f1");
idx = $(this).index();
$(".level2 > li").hide();
$(".level2 > li").eq(idx).show();
});
$(".level3").hide();
$(".level2 > li > ul > li").on("click", function() {
$(".level2 > li > ul > li").css("background-color", "transparent");
$(this).css("background-color", "#f1f1f1");
$(".level3").hide();
var idx2 = $(this).index();
var idx1 = $(this).parent().parent().index();
$(".level3").show();
$("#catid").val("CAT" + (idx1+1) + "-" + (idx2+1));
});
});
</script>
</head>
<body>
<div class="advtop">
</div>
<div id="topbar2">
<div id="lang">
<ul>
<li>
<a href="?lang=lt" ><img src="image/Lithuania.png" ></a>
</li>
<li>
<img src="image/United Kingdom.png" >
</li>
</ul>
</div>
<div id="text">
<ul>
<li>
<?php
if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
echo "Sveiki"; ?> <?php echo $_SESSION["username"]; ?><?php
}else {
?> <a href="post.php" ><?php echo $lang['LOGIN']; ?></a> <?php
}
?><span> |</span>
</li>
<li>
▽</span>
<ul class="dropdown">
<li><a class="first" href="#"><?php echo $lang['FAV']; ?> (0)</a></li>
<li><?php echo $lang['ADS']; ?></li>
<li><?php echo $lang['DETAILS']; ?></li>
<li>
<?php
if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
?> <a href="logout.php" ><?php echo $lang['LOGOUT']; ?></a> <?php
}else {
?> <a href="post.php" ><?php echo $lang['REGISTER']; ?></a> <?php
} ?>
</li>
</ul>
</li>
</ul>
</div>
<div id="postadv">
<a href="<?php
if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
echo "step1.php";
}else {
echo "post.php";
}
?>" ><?php echo $lang['POST']; ?></a>
</div>
</div>
<div id="logo2"><img src="image/logo.png"></div>
<div id="searchbox2">
<form class="form" action="search.php" method="get">
<input class="search-field" type="search" name="search" size="70" maxlength="50" placeholder="<?php echo $lang['SRC']; ?>" height="50">
<select class="categories" name="categories">
<option value="0" selected="selected"><?php echo $lang['ALLCAT']; ?></option>
<option value="1"><?php echo $lang['CAT1']; ?></option>
<option value="2"><?php echo $lang['CAT2']; ?></option>
<option value="3"><?php echo $lang['CAT3']; ?></option>
<option value="4"><?php echo $lang['CAT4']; ?></option>
<option value="5"><?php echo $lang['CAT5']; ?></option>
<option value="6"><?php echo $lang['CAT6']; ?></option>
<option value="7"><?php echo $lang['CAT7']; ?></option>
<option value="8"><?php echo $lang['CAT8']; ?></option>
<option value="9"><?php echo $lang['CAT9']; ?></option>
</select>
<input class="submit-button" type="submit" value="<?php echo $lang['SRCBTN']; ?>">
</form>
<a href="#" ><?php echo $lang['ADVSRC']; ?></a>
</div>
<div id="itemsCategLists">
<ul class="level1">
<li>
<span><?php echo $lang['CAT1']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT2']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT3']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT4']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT5']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT6']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT7']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT8']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT9']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
</ul>
<ul class="level2">
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT1-1']; ?></span></li>
<li><span><?php echo $lang['CAT1-2']; ?></span></li>
<li><span><?php echo $lang['CAT1-3']; ?></span></li>
<li><span><?php echo $lang['CAT1-4']; ?> </span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT2-1']; ?></span></li>
<li><span><?php echo $lang['CAT2-2']; ?></span></li>
<li><span><?php echo $lang['CAT2-3']; ?></span></li>
<li><span><?php echo $lang['CAT2-4']; ?></span></li>
<li><span><?php echo $lang['CAT2-5']; ?></span></li>
<li><span><?php echo $lang['CAT2-6']; ?></span></li>
<li><span><?php echo $lang['CAT2-7']; ?></span></li>
<li><span><?php echo $lang['CAT2-8']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT3-1']; ?></span></li>
<li><span><?php echo $lang['CAT3-2']; ?></span></li>
<li><span><?php echo $lang['CAT3-3']; ?></span></li>
<li><span><?php echo $lang['CAT3-4']; ?></span></li>
<li><span><?php echo $lang['CAT3-5']; ?></span></li>
<li><span><?php echo $lang['CAT3-6']; ?></span></li>
<li><span><?php echo $lang['CAT3-7']; ?></span></li>
<li><span><?php echo $lang['CAT3-8']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT4-1']; ?></span></li>
<li><span><?php echo $lang['CAT4-2']; ?></span></li>
<li><span><?php echo $lang['CAT4-3']; ?></span></li>
<li><span><?php echo $lang['CAT4-4']; ?></span></li>
<li><span><?php echo $lang['CAT4-5']; ?></span></li>
<li><span><?php echo $lang['CAT4-6']; ?></span></li>
<li><span><?php echo $lang['CAT4-7']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT5-1']; ?></span></li>
<li><span><?php echo $lang['CAT5-2']; ?></span></li>
<li><span><?php echo $lang['CAT5-3']; ?></span></li>
<li><span><?php echo $lang['CAT5-4']; ?></span></li>
<li><span><?php echo $lang['CAT5-5']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT6-1']; ?></span></li>
<li><span><?php echo $lang['CAT6-2']; ?></span></li>
<li><span><?php echo $lang['CAT6-3']; ?></span></li>
<li><span><?php echo $lang['CAT6-4']; ?></span></li>
<li><span><?php echo $lang['CAT6-5']; ?></span></li>
<li><span><?php echo $lang['CAT6-6']; ?></span></li>
<li><span><?php echo $lang['CAT6-7']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT7-1']; ?></span></li>
<li><span><?php echo $lang['CAT7-2']; ?></span></li>
<li><span><?php echo $lang['CAT7-3']; ?></span></li>
<li><span><?php echo $lang['CAT7-4']; ?></span></li>
<li><span><?php echo $lang['CAT7-5']; ?></span></li>
<li><span><?php echo $lang['CAT7-6']; ?></span></li>
<li><span><?php echo $lang['CAT7-7']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT8-1']; ?></span></li>
<li><span><?php echo $lang['CAT8-2']; ?></span></li>
<li><span><?php echo $lang['CAT8-3']; ?></span></li>
<li><span><?php echo $lang['CAT8-4']; ?></span></li>
<li><span><?php echo $lang['CAT8-5']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT9-1']; ?></span></li>
<li><span><?php echo $lang['CAT9-2']; ?></span></li>
<li><span><?php echo $lang['CAT9-3']; ?></span></li>
<li><span><?php echo $lang['CAT9-4']; ?></span></li>
</ul>
</li>
</ul>
<div class="level3">
<form id="step1" action="step2.php" method="post">
<input type="hidden" name="catid" id="catid">
<input class="submit-button" type="submit" name="submint" value="<?php echo $lang['NEXT']; ?>">
</form>
</div>
</div>
<div class="footer2">
<div class="copy">
<ul>
<li>
<a href="#" ><?php echo $lang['TERMS']; ?></a>
</li>
<li>
<a href="#" ><?php echo $lang['CONTACT']; ?></a>
</li>
</ul>
<span style="font-size: 13px; color: black"><?php echo $lang['COPY']; ?></span>
</div>
</div>
</body>
</html>
and step2.php
<?php
include_once 'common.php';
?>
<!DOCTYPE html>
<html lang="<?php echo $lang['LANG']; ?>">
<head>
<title><?php echo $lang['PAGE_TITLE']; ?></title>
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="js/ism-2.1.js"></script>
</head>
<body>
<div class="advtop">
</div>
<div id="topbar2">
<div id="lang">
<ul>
<li>
<a href="?lang=lt" ><img src="image/Lithuania.png" ></a>
</li>
<li>
<img src="image/United Kingdom.png" >
</li>
</ul>
</div>
<div id="text">
<ul>
<li>
<?php
if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
echo "Sveiki"; ?> <?php echo $_SESSION["username"]; ?><?php
}else {
?> <a href="post.php" ><?php echo $lang['LOGIN']; ?></a> <?php
}
?><span> |</span>
</li>
<li>
▽</span>
<ul class="dropdown">
<li><a class="first" href="#"><?php echo $lang['FAV']; ?> (0)</a></li>
<li><?php echo $lang['ADS']; ?></li>
<li><?php echo $lang['DETAILS']; ?></li>
<li>
<?php
if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
?> <a href="logout.php" ><?php echo $lang['LOGOUT']; ?></a> <?php
}else {
?> <a href="post.php" ><?php echo $lang['REGISTER']; ?></a> <?php
} ?>
</li>
</ul>
</li>
</ul>
</div>
<div id="postadv">
<a href="<?php
if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
echo "step1.php";
}else {
echo "post.php";
}
?>" ><?php echo $lang['POST']; ?></a>
</div>
</div>
<div id="logo2"><img src="image/logo.png"></div>
<div id="searchbox2">
<form class="form" action="search.php" method="get">
<input class="search-field" type="search" name="search" size="70" maxlength="50" placeholder="<?php echo $lang['SRC']; ?>" height="50">
<select class="categories" name="categories">
<option value="0" selected="selected"><?php echo $lang['ALLCAT']; ?></option>
<option value="1"><?php echo $lang['CAT1']; ?></option>
<option value="2"><?php echo $lang['CAT2']; ?></option>
<option value="3"><?php echo $lang['CAT3']; ?></option>
<option value="4"><?php echo $lang['CAT4']; ?></option>
<option value="5"><?php echo $lang['CAT5']; ?></option>
<option value="6"><?php echo $lang['CAT6']; ?></option>
<option value="7"><?php echo $lang['CAT7']; ?></option>
<option value="8"><?php echo $lang['CAT8']; ?></option>
<option value="9"><?php echo $lang['CAT9']; ?></option>
</select>
<input class="submit-button" type="submit" value="<?php echo $lang['SRCBTN']; ?>">
</form>
<a href="#" ><?php echo $lang['ADVSRC']; ?></a>
</div>
<div id="itemsCategLists2">
<div class="post2" >
<form class="formstyle" action="final.php" method="post" >
<div class="adtext">
<p><b><?php echo $lang['KAT']; ?>:</b>
</p>
<p><b><?php echo $lang['ACTION']; ?>*:</b>
</p>
<p><b><?php echo $lang['ADTITLE']; ?>*:</b><br>
</p>
<p><b><?php echo $lang['ADDETAILS']; ?>*:</b>
</p><br><br><Br>
<p><b><?php echo $lang['PRICE']; ?>*:</b>
</p>
<p><b><?php echo $lang['ADPHOTOS']; ?>:</b>
</p>
<p><b><?php echo $lang['UARE']; ?>*:</b>
</p>
<p><b><?php echo $lang['PHONE']; ?>*:</b>
</p>
<p><b><?php echo $lang['EMAIL']; ?>:</b>
</p>
<p><b><?php echo $lang['LOCATION']; ?>*:</b>
</p>
<p><b><?php echo $lang['NAME']; ?>*:</b>
</p>
<p><b><?php echo $lang['WEB']; ?>:</b>
</p>
</div>
<div class="entry">
<?php
$catid = $_POST['catid'];
$catid2 = substr($catid,0,4);
$cat1 = $lang[$catid2];
$cat2 = $lang[$catid];
echo "<font color='grey'>".$cat1." » ".$cat2."</font>";
?>
<br style="margin-bottom: 17px;">
<input type="hidden" name="catid" value="<?php echo $catid; ?>">
<input type="radio" name="action" value="1" required> <?php echo $lang['PORPOSE']; ?>
<input type="radio" name="action" value="2" required> <?php echo $lang['LOOKING']; ?><br style="margin-bottom: 15px;">
<input type="text" name="title" maxlength="80" pattern=".{10,}" title="At Least 10 symbols" min="10" style="width: 379px;" required><br style="margin-bottom: 15px;">
<textarea name="details" rows="10" cols="30" pattern=".{10,}" title="At Least 10 symbols" style="width: 379px; height: 75px;" maxlength="5500" required></textarea><br><br style="margin-bottom: 5px;">
<input type="text" name="price" maxlength="10" pattern="\d+(\.\d{2})?" title="Only numbers" required><br style="margin-bottom: 15px;">
<input type="file" multiple="true" name="image[]"><br style="margin-bottom: 15px;">
<input type="radio" name="ocp" value="1" required><?php echo $lang['PRV']; ?>
<input type="radio" name="ocp" value="2" required><?php echo $lang['BSN']; ?><br style="margin-bottom: 15px;">
<input type="text" name="phonenumber" pattern="^\s*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$" title="Only UK Phone numbers ( 07*********) " required><br style="margin-bottom: 15px;">
<input type="email" name="email"><br style="margin-bottom: 15px;">
<input type="text" name="location" pattern=".[A-Za-z]{3,15}" title="Only letter (4-15 symbols)" required><br style="margin-bottom: 15px;">
<input type="text" name="name" pattern=".[A-Za-z]{3,15}" title="Only letter (4-15 symbols)" required><br style="margin-bottom: 15px;">
<input type="text" name="web" pattern="www\.\w+\.\w{2,3}|www\.\w+\.\w{2,3}\.\w{2}" title="Format :(www.website.com) "><br style="margin-bottom: 15px;">
<input class="submit-button" type="submit" name="submit" value="<?php echo $lang['POSTADV']; ?>">
</div>
</form>
</div>
</div>
<div class="footer2">
<div class="copy">
<ul>
<li>
<a href="#" ><?php echo $lang['TERMS']; ?></a>
</li>
<li>
<a href="#" ><?php echo $lang['CONTACT']; ?></a>
</li>
</ul>
<span style="font-size: 13px; color: black"><?php echo $lang['COPY']; ?></span>
</div>
</div>
</body>
</html>
okay so i think a little and find a solution for this not the best one but its seams no1 else can help me except my self so what i will try to do is check if a catid is isset and if not then just redirect back to a step1 so if some1 try to access the step2 page it will just redirect to step1 because catid will be not isset and same with language when i change language catid becomes not isset and it should redirect me to step1 page , tell me if i am thinking a right way and if not what i am doing wrong