HTTP GET isn't working? - html

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_.

Related

perform action when button is clicked php

I'm trying to create a form using php in which the user will input some data, and I'll be able to store them in my database.
so far my code is this
<h1>Join Head Hunters <span class="colored-text">NOW</span>!</h1>
<form class="sform" method="get">
<input type="text" name="username" value="" placeholder="Username" method="get" maxlength="30">
<input type="password" name="password" value="" placeholder="Password" method="get" maxlength="30">
<input type="text" name="first_name" value="" placeholder="First name" method="get" maxlength="30">
<input type="text" name="last_name" value="" placeholder="Last name" method="get" maxlength="30">
<input type="text" name="address" value="" placeholder="Address" method="get" maxlength="80">
<input type="text" name="phone" value="" placeholder="Phone" method="get" maxlength="60">
<input type="text" name="mail" value="" placeholder="email" method="get" maxlength="40">
<input type="text" name="prof" value="" placeholder="Profession" method="get">
<input type="text" name="account" value="" placeholder="Bank Account" method="get">
<select multiple id="studies" class="specialColor" method="get">
<option value="highschool degree">Highschool Degree</option>
<option value="bachelors degree">Bachelors Degree</option>
<option value="MSc">MSc</option>
<option value="PhD">PhD</option>
<option value="MD">MD</option>
<option value="EdD">EdD</option>
<option value="JD">JD</option>
</select>
<select multiple="multiple" id="skillz" name="skillz[]" method="get">
<option value="administering programs">Administering Programs</option>
<option value="advising people">Advising people</option>
<option value="analyzing data">Analyzing data</option>
<option value="assembling apparatus">Assembling apparatus</option>
<option value="auditing financial reports">Auditing financial reports</option>
<option value="budgeting expenses">Budgeting expenses</option>
<option value="calculating numerical data">Calculating numerical data</option>
<option value="finding information">Finding information</option>
<option value="handling complaints">Handling complaints</option>
<option value="imagining new solutions">Imagining new solutions</option>
<option value="interpreting languages">Interpreting languages</option>
<option value="speaking to the public">Speaking to the public</option>
<option value="writing letters/papers/proposals">Writing letters/papers/proposals</option>
<option value="listening to others">Listening to others</option>
<option value="deciding uses of money">Deciding uses of money</option>
<option value="determining a problem">Determining a problem</option>
<option value="setting work/committee goals">Setting work/committee goals</option>
<option value="maintaining emotional control under stress">Maintaining emotional control under stress</option>
</select>
<select multiple="multiple" id="languages" name="languages[]" method="get">
<option value="english">English</option>
<option value="greek">Greek</option>
<option value="german">German</option>
<option value="japanese">Japanese</option>
<option value="spanish">Spanish</option>
<option value="italian">Italian</option>
<option value="french">French</option>
<option value="wookie">Wookie</option>
<option value="klingon">Klingon</option>
<option value="other">Other</option>
</select>
<input type="submit" class="button" name='create_account' value="Create Account"></input>
</form>
and the PHP for that:
<?php
$sservername = "localhost";
$susername = "root";
$spassword = "";
$sdbname = "projectDB";
mysql_connect($sservername, $susername, $spassword) or die("Cannot connect to server.");
mysql_select_db($sdbname) or die("Cannot select DataBase.");
if (isset($_POST["create_account"])) {
echo "<br><br><br><br><br>Button clicked";
//header("Location: signupsuccess.php");
$email_exp = '/^[A-Za-z0-9._%-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
//some error checking, now...
if (!preg_match($email_exp, $mail)) {
$error_message .= "<font color='red'>The Email address you entered does not appear to be valid.<br/></font>";
header("Refresh:0");
echo $error_message;
}
}
?>
Problem is that no matter how many times I try and press the button it never echos the "Button clicked" message and I can't figure out why!
Keep in mind, this is my first attempt on php and mysql. Any help? I've googled too much and I can't figure out my mistake.
<form class="sform" method="get">
if (isset($_POST["create_account"]))
A GET form will put the data in the query string, not the request body. $_POST won't be populated. Set the method to post.
Additionally, at present you are always going to output the Refresh 0 header, so it is quite likely that even if you did output the HTML then the page would refresh immediately and you wouldn't see it.

Select field or Text field

I have a select with many options. If a user doesn't find value in option, He could fill a "other" field :
<select name="value">
<option>Choose...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="text" name="value">
In this case, if I choose a value in the select, it appeared blank beacause of the text fiel.
Thanks
I imagined it, needs to be improved
http://jsfiddle.net/neiesc/jv6qgn03/
<select name="value">
<option>Choose...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<br />
<label for="chkOther">
Other
<input id="chkOther" type="checkbox" value="0" />
</label>
<input id="txtOther" type="text" name="value" disabled>
Javascript code:
$( "#chkOther" ).click(function() {
$( "#txtOther" ).prop( "disabled", !$( "#txtOther" ).prop( "disabled"));
});
Use different names for select and text input.
<form method="post">
<select name="select">
<option>Choose...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="text" name="field">
<input type="submit" name="submit">
</form>
And in PHP check what was chosen:
<?php
if (isset($_POST['submit'])) {
// form was sent
if (!empty($_POST['select'])) {
// select or both, use select
} elseif (!empty($_POST['input'])) {
// empty select txt input filled
} else {
// nothing chose in select and text input is blank
}
}
?>

page/form cutting off at 100% height

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.

Form not submitting files

For some reason the following form isn't submitting the file like it should and I'm unsure why, on the server side if I check $_FILES it is always empty however if I check say $_POST['article'] that submit just fine, so only the file isn't being received then does anyone see something wrong with this?
<form action="newindex.php?do=submit" enctype="multipart/form-data" method="post">
Subject:<br>
<input type="text" id="subject" name="subject"><br>
<textarea id="article" id="article" name="article"></textarea><br>
<div class="sliderimage"><h2 class="blockhead">Slider Image:</h2>
<table><tr><td><b>Image:</b><br>Dimensions should be 640x360.</td><td>
<input type="file" id="image" name="image"></td></tr>
<tr><td><b>Transition:</b></td><td>
<select id="transition" name="transition">
<option value="">Random</option>
<option value="sliceDown">slideDown</option>
<option value="sliceDownLeft">sliceDownLeft</option>
<option value="sliceUp">sliceUp</option>
<option value="sliceUpLeft">sliceUpLeft</option>
<option value="fold">fold</option>
<option value="fade">fade</option>
<option value="slideInRight">slideInRight</option>
<option value="slideInLeft">slideInLeft</option>
<option value="boxRandom">boxRandom</option>
<option value="boxRain">boxRain</option>
<option value="boxRainReverse">boxRainReverse</option>
<option value="boxRainGrow">boxRainGrow</option>
<option value="boxRainGrowReverse">boxRainGrowReverse</option>
</select></td></tr>
<tr><td><b>Caption:</b></td><td>
<input type="text" id="caption" name="caption"></table><br></div>
<input type="hidden" name="securitytoken" value="<?php echo $vbulletin->userinfo['securitytoken'] ?>" />
<div class="center"><input type="button" value="Preview" class="preview"><input type="submit" name="submit"></div>
</form>
You need to have an input specifying the max file size:
http://www.php.net/manual/en/features.file-upload.post-method.php
put the size attribute in the and this will work.
<input id="image" name="image" type="file" size = '50'"/>

html input field issue

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?