I am working on building an options page for a small website I am working on, but I have run into a rather interesting error. The bottom of my form seems to abruptly cut off at 100% browser height as seen in this picture:
http://oi39.tinypic.com/fm8cia.jpg
As soon as I refresh the page (F5), the form completes and everything works fine as seen in this picture:
http://oi40.tinypic.com/9zqerc.jpg
After fiddling with it for a while, I have noticed that the issue seems to reside with my tag, for when I remove it, the problem goes away.
Here is the code for my form tag:
<form action="r_options.php" method="post">
<label id="edit_account_label"><b>OPT_MINADMIN</b> - Minimum level to view the control panel.</label>
<select name = "opt_minadmin" style="float:right;">
<option value = "<?php echo $opt['OPT_MINADMIN']; ?>"><?php echo $opt['OPT_MINADMIN']; ?></option>
<option value = "1">1</option>
<option value = "2">2</option>
<option value = "3">3</option>
</select>
<br><br>
<label id="edit_account_label"><b>OPT_MINEN</b> - Minimum level to edit the manager/homepage notes.</label>
<select name = "opt_minen" style="float:right;">
<option value = "<?php echo $opt['OPT_MINEN']; ?>"><?php echo $opt['OPT_MINEN']; ?></option>
<option value = "1">1</option>
<option value = "2">2</option>
<option value = "3">3</option>
</select>
<br><br>
<label id="edit_account_label"><b>OPT_MINADD</b> - Minimum level to add users to the system.</label>
<select name = "opt_minadd" style="float:right;">
<option value = "<?php echo $opt['OPT_MINADD']; ?>"><?php echo $opt['OPT_MINADD']; ?></option>
<option value = "1">1</option>
<option value = "2">2</option>
<option value = "3">3</option>
</select>
<br><br>
<label id="edit_account_label"><b>OPT_MINEDIT</b> - Minimum level to edit users in the system.</label>
<select name = "opt_minedit" style="float:right;">
<option value = "<?php echo $opt['OPT_MINEDIT']; ?>"><?php echo $opt['OPT_MINEDIT']; ?></option>
<option value = "1">1</option>
<option value = "2">2</option>
<option value = "3">3</option>
</select>
<br><br>
<label id="edit_account_label"><b>OPT_MINDELETE</b> - Minimum level to delete users in the system.</label>
<select name = "opt_mindelete" style="float:right;">
<option value = "<?php echo $opt['OPT_MINDELETE']; ?>"><?php echo $opt['OPT_MINDELETE']; ?></option>
<option value = "1">1</option>
<option value = "2">2</option>
<option value = "3">3</option>
</select>
<br><br>
<label id="edit_account_label"><b>OPT_MINPOINT</b> - Minimum level use the attendance system.</label>
<select name = "opt_minpoint" style="float:right;">
<option value = "<?php echo $opt['OPT_MINPOINT']; ?>"><?php echo $opt['OPT_MINPOINT']; ?></option>
<option value = "1">1</option>
<option value = "2">2</option>
<option value = "3">3</option>
</select>
<br><br>
<label id="edit_account_label"><b>OPT_MINSG</b> - Minimum level to edit the sales goals.</label>
<select name = "opt_minsg" style="float:right;">
<option value = "<?php echo $opt['OPT_MINSG']; ?>"><?php echo $opt['OPT_MINSG']; ?></option>
<option value = "1">1</option>
<option value = "2">2</option>
<option value = "3">3</option>
</select>
<br><br>
<label id="edit_account_label"><b>OPT_MINSCHED</b> - Minimum level to edit the schedule suite.</label>
<select name = "opt_minsched" style="float:right;">
<option value = "<?php echo $opt['OPT_MINSCHED']; ?>"><?php echo $opt['OPT_MINSCHED']; ?></option>
<option value = "1">1</option>
<option value = "2">2</option>
<option value = "3">3</option>
</select>
<br><br>
<label id="edit_account_label"><b>P_NOSHOW</b> - Points given per noshow.</label>
<input type="text" name="p_noshow" value="<?php echo $opt['P_NOSHOW']; ?>" style="width:28px;float:right;" />
<br><br>
<label id="edit_account_label"><b>P_CALLED</b> - Points given for calling in sick.</label>
<input type= "text" name="p_called" value="<?php echo $opt['P_CALLED']; ?>" style="width:28px;float:right;" />
<br><br>
<label id="edit_account_label"><b>P_LEAVE</b> - Points given for employees leaving early.</label>
<input type="text" name="p_leave" value="<?php echo $opt['P_LEAVE']; ?>" style="width:28px;float:right;" />
<br><br>
<label id="edit_account_label"><b>P_LATE</b> - Points given for employees coming in late.</label>
<input type="text" name="p_late" value="<?php echo $opt['P_LATE']; ?>" style="width:28px;float:right;" />
<br><br>
<label id="edit_account_label"><b>P_PUNCH</b> - Points given for employees missing a punch in/out.</label>
<input type="text" name="p_punch" value="<?php echo $opt['P_PUNCH']; ?>" style="width:28px;float:right;" />
<br><br>
<label id="edit_account_label"><b>P_PERIOD</b> - How long the points period is. (in days)</label>
<input type="text" name="p_period" value="<?php echo $opt['P_PERIOD']; ?>" style="width:28px;float:right;" />
<br><br>
<label id="edit_account_label"><b>SESSION_TIMEFUNC</b> - Use the timeout feature?</label>
<select name = "session_timefunc" style="float:right;">
<option value = "<?php echo $opt['SESSION_TIMEFUNC']; ?>"><?php echo $opt['SESSION_TIMEFUNC']; ?></option>
<option value = "true">true</option>
<option value = "false">false</option>
</select>
<br><br>
<label id="edit_account_label"><b>REG_NAME</b> - Who is this software registered to?</label>
<input type="text" name="reg_name" value="<?php echo $opt['REG_NAME']; ?>" style="float:right;" />
<br><br>
<input type="submit" name="submit" value="Update Options" style="margin:auto;" onclick="return confirm('Update Options?')" />
</form>
Here is the CSS for the ID edit_account_label:
#edit_account_label {
padding-bottom: 10px;
float: left;
}
This problem only occurs in Google Chrome (Version 26.0.1410.64 m), the code works fine in Internet Explorer 9 with no problems.
I apologize for my sloppy code, I am no professional.
Related
In below test code I try to save and use 3 $_POST variables. But only the last $_POST variable is stored. The rest is overwritten with the last $_POST variable.
Purpose of the question is to select first the wanted country. Select from a table the country as selected. Then select the wanted a car_brand from the selected country. Then select the wanted company and filter this from the selected country+car_brand.
I have tried to store the 3 $_POST into a $_SESSION also tried it with $_REQUEST via type="hidden" without getting the 3 $_POST variables.
Question: what do I do wrong and how can I solve this problem?
session_start();
$content .= ' <form id="sel_country" method="POST">
<select name="country" onchange="this.form.submit()" >
<option value="NL">Netherlands</option>
<option value="DE">German</option>
<option value="GB">England</option>
</select>
</form>';
$content .= '<form id="sel_car_brand" method="POST">
<select name="brand" onchange="this.form.submit()" >
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="audi">Audi</option>
</select>
</form>';
$content .= ' <form id="sel_company" method="POST">
<select name="company" onchange="this.form.submit()">
<option value="dealer">Dealer</option>
<option value="service">Service</option>
<option value="import">Importer</option>
</select>
</form>';
$_SESSION['country'] = $_POST['country'];
$_SESSION['brand'] = $_POST['brand'];
$_SESSION['company'] = $_POST['company'];
var_dump($_SESSION) ;
Had a session_start() at the beginning and then stock your variable in it. Like $_SESSION['country'] = $_POST['country'] when $_POST['country'] is defined (do a var_dump() to verify it) and you'll be able to access your datas stocked in your $_SESSION.
session_start();
$content .= ' <form id="sel_country" method="POST">
<select name="country" onchange="this.form.submit()" >
<option value="NL">Netherlands</option>
<option value="DE">German</option>
<option value="GB">England</option>
</select>
</form>';
$_SESSION['country'] = $_POST['country'];
$content .= '<form id="sel_car_brand" method="POST">
<select name="brand" onchange="this.form.submit()" >
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="audi">Audi</option>
</select>
</form>';
$_SESSION['brand'] = $_POST['brand'];
$content .= ' <form id="sel_company" method="POST">
<select name="company" onchange="this.form.submit()">
<option value="dealer">Dealer</option>
<option value="service">Service</option>
<option value="import">Importer</option>
</select>
</form>';
$_SESSION['company'] = $_POST['company'];
var_dump($_SESSION) ;
// Edited by moliets: var_dump response: array(3) { ["country"]=> NULL ["brand"]=> NULL ["company"]=> string(6) "import" }
I have a form on a webpage that will submit data in the fields to be processed on another page.
Here is the form:
<form align="center" action="submitrivalsconfig.php" method="get">
<b>PN Operator:</b>
<select name="PNOp" value="<?php echo $data["PNOp"]?>">
<option value="=">=</option>
<option value=">">></option>
<option value="<"><</option>
<option value=">=">>=</option>
<option value="<="><=</option>
</select>
<b>PN Value: </b>
<input type="number" name="PNValue" value="<?php echo $data["PNValue"]?>" style="width:40px">
<br><br>
<b>MEL Operator:</b>
<select name="MELOp" value="<?php echo $data["MELOp"]?>">
<option value="=">=</option>
<option value=">">></option>
<option value="<"><</option>
<option value=">=">>=</option>
<option value="<="><=</option>
</select>
<b>MEL Value:</b>
<input type="number" name="MELValue" value="<?php echo $data["MELValue"]?>" style="width:40px">
<br><br>
<b>NDZ Operator:</b>
<select name="NDZOp" value="<?php echo $data["NDZOp"]?>">
<option value="=">=</option>
<option value=">">></option>
<option value="<"><</option>
<option value=">=">>=</option>
<option value="<="><=</option>
</select>
<b>NDZ Value: </b>
<input type="number" name="NDZValue" value="<?php echo $data["NDZValue"]?>" style="width:40px">
<br><br>
<b>Fuel Type:</b>
<input type="text" name="FuelType" value="<?php echo $data["FuelType"]?>" style="width:400px">
<br><br>
<input type="submit" value="Submit Configuration">
</form>
Upon pressing the submit button, I am redirected to the following url:
bmratest/minipages/submitrivalsconfig.php?PNOp=%3D&PNValue=54&MELOp=%3D&MELValue=60&NDZOp=%3D&NDZValue=90&FuelType=%27CCGT%27%2C+%27COAL+IN%27%2C+%27COAL+OUT%27%2C+%27OCCGT%27%2C+%27OIL%27
Everything seems fine to me so far, but I assigned the data transferred to an array and it outputs blanks, suggesting that the $_GET details are blank and it isn't reading the information from the URL.
The superglobal you are looking for is called $_GET not $GET_.
Hi I would like to hear if there are alternatives for these forms
so I dont have to write for every single option
1. For the age form
For the country form
<select name="age">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<!--And again and again and... again-->
<option value="99">99</option>
</select>
<select name="country">
<option value="England">England</option>
<option value="Sweeden">Sweeden</option>
<option value="Norway">Norway</option>
<option value="Denmark">Denmark</option>
<option value="Usa">Usa</option>
<option value="Spain">Spain</option>
<option value="Scotland">Scotland</option>
<option value="Ireland">Ireland</option>
<option value="French">French</option>
<option value="Italy">Italy</option>
<option value="Germany">Germany</option>
<option value="Poland">Poland</option>
<option value="Netherland">Netherland</option>
<option value="Australia">Australia</option>
<option value="China">China</option>
<option value="Japan">Japan</option>
<option value="Singapore">Singapore</option>
<option value="Russia">Russia</option>
<option value="Other">Other</option>
</select>
Hope you understand my question. Sos for bad english
There is a HTML "range" input, but it's not the most common input method out there and will require some javascript with it. Other than that, the only reasonable method is PHP. Though, if you do use PHP, you can copy and paste the HTML and then insert it into your HTML file if you don't want that page to have PHP. Below are a few HTML only examples. May not work in all browsers, so your server side code should always validate. http://jsfiddle.net/h96nU/1/
The below code shows a few inputs using various methods. The range input will update to show the range value that is currently selected. The last number input uses the HTML5 pattern attribute.
input:invalid {
border: 1px solid red;
}
input:valid {
border: 1px solid green;
}
<div>
<input id="range" type="range" min="1" max="120" step="1" />
<span id="range_value">0</span>
</div>
<div>
<input type="number" />
</div>
<div>
<input type="text" />
</div>
<div>
<input type="number" min="1" max="120" step="1" id="n1" name="age" pattern="\d+" />
</div>
var input = document.getElementById('range');
input.addEventListener('change',input_change,false);
function input_change(e) {
var target = e.target || e.srcElement;
var value = target.value;
var showdiv = document.getElementById('range_value');
showdiv.textContent = value;
}
More about Data Validation in HTML can be found at https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Data_form_validation
For PHP method of an age input loop, look below.
<?php
$min = 1;
$max = 100;
echo '<select name="age">';
for($i = $min; $i <= $max; $i++) {
echo '<option value="'.$i.'">'.$i.'</option>';
}
echo '</select>';
?>
If you are using PHP for example you could do it like this:
<?php
$myArray = ['USA','Australia','ETC ETC ETC'];
echo '<select name="country">';
foreach ($myArray as $value) {
echo '<option value="'.$value.'">';
echo $value;
echo "</option>";
}
echo "</select>";
?>
The output of this example would be :
<select name="country">
<option value="USA">USA</option>
<option value="Australia">Australia</option>
<option value="ETC ETC ETC">ETC ETC ETC</option>
</select>
For your age selectbox:
<?php
$maxAge = 99;
echo '<select name="age">';
for ($i=1; $i < $maxAge; $i++) {
echo '<option value="'.$i.'">';
echo $i;
echo "</option>";
}
echo "</select>";
?>
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I found an error in my code when i try to insert my form in db...
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '' at line 2
Form:
<div class="form">
<form id="contactform" method="POST" action="">
<p class="contact"><label for="name">Name</label></p>
<input id="name" name="name" placeholder="First and last name" required="" tabindex="1" type="text" value="<?php echo $name;?>">
<p class="contact"><label for="email">Email</label></p>
<input id="email" name="email" placeholder="example#domain.com" required="" type="email" value="<?php echo $email;?>">
<p class="contact"><label for="username">Create a username</label></p>
<input id="username" name="username" placeholder="username" required="" tabindex="2" type="text" value="<?php echo $username;?>">
<p class="contact"><label for="password">Create a password</label></p>
<input type="password" id="password" name="password" required="" placeholder="Set password">
<p class="contact"><label for="repassword">Confirm your password</label></p>
<input type="password" id="repassword" name="repassword" required="" placeholder="Confirm password"> </br>
<label>Birthday</label></br>
<select class="select-style" name="birthMonth" >
<option value="" class="nothing">Month</option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03" >March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12" >December</option>
</select>
<select class="select-style" name="birthDay" required="">
<option value="" class="nothing">Day</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<input class="birthyear" maxlength="4" name="birthYear" placeholder="Year" required="" value="<?php echo $birthYear;?>">
</br>
<label>Gender</label>
<select class="select-style" style="width:400px;" name="gender" >
<option class="nothing" value="select">i am..</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="others">Other</option>
</select><br><br>
<input class="buttom" name="submit" id="submit" tabindex="5" value="Sign me up!*" type="submit">
<font style="color:white; size:10px; background-color:black"> * - By clicking on "Sign me up" button, you completly agree with <u>Terms & Conditions of use</u> .</font>
Validate:
if(isset($_POST['submit'])){
//VARIABLES
$name = $_POST['name'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
$confPass = $_POST['repassword'];
$birthDay = $_POST['birthDay'];
$birthMonth = $_POST['birthMonth'];
$birthYear = $_POST['birthYear'];
$gender = $_POST['gender'];
$type = 'user';
$birthday = date($birthDay."/".$birthMonth."/".$birthYear);
$date0 = mktime(0,0,0,date("m"),date("d"),date("Y"));
$today = date("Y/m/d", $date0);
echo '<script type="text/javascript">','hideTerms();','</script>';
if(strlen($password) < 5 or $password != $confPass){
echo "<span id='abouTitle'> Something wrong..</span>";
echo "<script type='text/javascript'> alert('Password too small or different');</script>";
}else{
echo "<span id='abouTitle'>Bem-Vindo, ".$username."!</span></br></br>";
echo '<font style="color:white; font-size:20px;"';
echo 'Name: '.$name.'</br>Email: '.$email.'</br>Username: '.$username.'</br>Password: <u>-Check your email-</u> </br>Birthday: '.$birthday.'</br>Gender: '.$gender.'</br>Account type: '.$type.'</br>Account Creation Day: '.$today.'</br>';
include ('php/content/connect.php');
$sql = mysql_query("INSERT INTO users (name, email, username, password, /*birthday,*/ gender, accountType/*, creationDate*/)
VALUES ( '$name', '$email', '$username', '$password',/*STR_TO_DATE('$birthYear,$birthMonth,$birthDay','%Y,%m,%d'),*/ '$gender', '$type'/*, '$today'*/") or die(mysql_error());
$data = mysql_query($sql);
$termina = mysql_close($conexao);
}
}else{
$name = "";
$email = "";
$birthYear ="";
$username = "";
}echo '</font>';
?>
Problem of parenthesis at the end of the syntax, you are closing the VALUES parenthesis but not the mysql_query one:
mysql_query("INSERT INTO users (name, email, username, password, /*birthday,*/ gender, accountType/*, creationDate*/)
VALUES ( '$name', '$email', '$username', '$password',/*STR_TO_DATE('$birthYear,$birthMonth,$birthDay','%Y,%m,%d'),*/ '$gender', '$type'/*, '$today'*/ )")
i'm new to html and this is probably a stupid mistake but i cant spot it. Whenever i select a input field, the cursor always jumps to the first input box. I'm guessing i missed an ending statement somewhere but i cant spot it...
<form method = "POST" action="changeCourse.php";>
<label for="newModule">Module:<label>
<input type="text" name="newModule" input value = "<?php echo $_REQUEST['modules'];?>"/>
<label for="newCode">Code:</label>
<input type="text" name="newCode" input value = "<?php echo $_REQUEST['codes'];?>"/>
<label for="newLesson">Lesson Type</label>
<select name="newLesson" id="newLesson">
<OPTION SELECTED><?php echo $_REQUEST['lesson_types'];?></option>
<option label="newLesson">Lecture</option>
<option label="newLesson">Tutorial</option>
</select>
<label for="newCredit">Credit:</label>
<input type="text" name="newCredit" input value = "<?php echo $_REQUEST['credits'];?>"/>
<label for="newLevel">Level</label>
<select name="newLevel" id="newLevel">
<OPTION SELECTED><?php echo $_REQUEST['levels'];?></option>
<option label="newLevel">4</option>
<option label="newLevel">5</option>
<option label="newLevel">6</option>
</select>
<label for="newCore">Core:</label>
<input type="text" name="newCore" input value = "<?php echo $_REQUEST['cores'];?>"/>
<label for="newLab">Lab Number:</label>
<input type="text" name="newLab" input value = "<?php echo $_REQUEST['labs'];?>"/>
<label for="facilities">Lab Facilities</label>
<select name="facilities" id="day">
<OPTION SELECTED><?php echo $_REQUEST['facilities'];?></option>>
<option label="facilities">Full(MS Office, Programming Packages, Adobe Packages)</option>
<option label="facilities">Partial(MS Office, Adobe Packages)</option>
<option label="facilities">Simple(MS Office)</option>
</select>
<label for="newTeacher">Teacher:</label>
<input type="text" name="newTeachers" input value = "<?php echo $_REQUEST['teachers'];?>"/>
<label for="newDay">Day</label>
<select name="newDay" id="day">
<OPTION SELECTED><?php echo $_REQUEST['days'];?></option>
<option label="newDay">Monday</option>
<option label="newDay">Tuesday</option>
<option label="newDay">Wednesday</option>
<option label="newDay">Thursday</option>
<option label="newDay">Friday</option>
</select>
<label for="newTime">Time:</label>
<input type="text" name="newTime" input value = "<?php echo $_REQUEST['times'];?>"/>
<label for="newComment">Additional Comments:</label>
<textarea style="resize: none;" cols="30" rows="3" name="newComment"> hello </textarea>
<input type="submit" value="Update Record" />
<input type="hidden" name="id" value="<?php echo $_REQUEST['ids'];?>">
</form>
Not sure if this is the reason but you have a bunch of input value's and it should only be value drop the input
First of all, you should fix your HTML. Open up your page in the browser, show the HTML source code and copy and paste it as direct input to an HTML validator. Fix all mentioned issues, and try again.
Do you still have the problem once your HTML is fixed?