PHP - Form $_post Problem!
Hi there I'm trying to make this form submit...but alas, is to no avail .... i have two forms on top of each other one of them is:
Code: [Select] <form name="entries_form" method="post" action="index.php"> <table> <tr> <th><label>Date</label></th> <th><label>From</label></th> <th><label>To</label></th> <th><label>Break</label></th> <th><label>Hours</label></th> <th><label>Required Hours</label></th> <th><label>Notes</label></th> </tr> <tr> <td> <input name="Date" type="text" id="Date" /> </td> <td> <input name="From" type="text" id="From" /> </td> <td> <input name="To" type="text" id="To" /> </td> <td> <input name="Break" type="text" id="Break" /> </td> <td> <input name="Hours" type="text" id="Hours" /> </td> <td> <input name="Rqrd_hrs" type="text" id="Rqrd_hrs" /> </td> <td> <input name="Notes" type="text" id="Notes" /> </td> <td> <input type="submit" name="Save" value="Save" id="Save" style="background-color:#7A70A4;" /> </td> </tr> </table> </form> to post i'm using this code (to much over the top maybe): Code: [Select] <?php $session = new Session(); $u_id = $session->get('id'); //to get the user id from session if(isset($_POST['submit']) == 'Save'){//form's button name is Save $entry->user_id = $user_id = $u_id; $entry->date = $date = trim(strtolower($_POST['Date'])); $entry->start_time = $start_time = trim(strtolower($_POST['From'])); $entry->end_time = $end_time = trim(strtolower($_POST['To'])); $entry->breaks = $break = trim(strtolower($_POST['Break'])); $entry->total_hours = $total_hours = trim(strtolower($_POST['Hours'])); $entry->reqd_hours = $required_hours = trim(strtolower($_POST['Rqrd_hrs'])); $entry->notes = $notes = trim(strtolower($_POST['Notes'])); $entry->add_entry(); }else die("Not Posted"); ?> the add entry() function does the following: Code: [Select] public function add_entry(){ global $database; $sql = "INSERT INTO sheetentries ("; $sql .= "user_id, date, start_time, end_time, break, required_hours, total_hours, notes"; $sql .= ") VALUES ('"; $sql .= $this->user_id ."', '"; $sql .= $this->date ."', '"; $sql .= $this->start_time ."', '"; $sql .= $this->end_time ."', '"; $sql .= $this->breaks ."', '"; $sql .= $this->reqd_hours ."', '"; $sql .= $this->total_hours ."', '"; $sql .= $this->notes ."')"; $database->query($sql); } the user_id or $u_id brought from the session when the user loggs in: Code: [Select] $u_id = $session->get('id'); anyway, whenever i try submitting the form nothing happens, what am i missing,,, thanks in advance Similar TutorialsHi All, I am having a bit of difficulty with a form I've built that has some PHP elements in it. The issue is it is just not sending the values (which are in hidden fields). Code is: Code: [Select] while($row = mysql_fetch_array($result)){ echo '<tr style="padding: 15px;">'; echo '<td>' . $row['product_id'] . '</td>'; echo '<td>' . $row['name'] . '</td>'; echo '<td>' . $row['catalogue_id'] . '</td>'; ?> <td> <form method="post" enctype="multipart/form-data" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"> <!--Hidden Field Checks to see if form has already been sent--> <input type="hidden" name="editform" value="Y"> <!--Hidden Fields for Edit Job--> <input type="hidden" name="prodid" value="<?php echo $row['product_id'] ?>"> <input type="hidden" name="prodname" value="<?php echo $row['name'] ?>"> <input type="hidden" name="catalogue_id" value="<?php echo $row['catalogue_id'] ?>"> <input type="hidden" name="full_description" value="<?php echo $row['full_description'] ?>"> <input type="submit" name="Edit" value="<?php _e('Edit', 'pmimp_trdom' ) ?>" /> </form> </td> Would it have something to do with splitting up the php tags? Any help would be apprecited! Thanks! can someone visually just read through my code and let me know if this looks like it'll work? I'm not getting any errors in my IDE so now I want to double check the structure <?php require_once '/usr/local/cpanel/3rdparty/lib/php/Mail.php'; $db_server = 'localhost'; $db_user = '-----'; $db_pass = '-----'; $dbc = mysql_connect ($db_server, $db_user, $db_pass); if (!$dbc) { die(mysql_error()); header ('Location: /contact'); exit; } if ($_POST['contactsent'] != 'yes') { header ('Location: /contact'); exit; } else { if (is_array($_POST)) { foreach ($_POST as $key => $value) { $_POST[$key] = mysql_real_escape_string(stripslashes($value)); } } $RequestType = $_POST["RequestType"]; $ConsumerBusiness = $_POST["ConsumerBusiness"]; $GlobalLocation = $_POST["GlobalLocation"]; $FirstName = strtolower(str_replace("'","''",$_POST["FirstName"])); $FirstName = strtoupper(substr($FirstName,0,1)).substr($FirstName,1); $LastName = strtolower(str_replace("'","''",$_POST["LastName"])); $LastName = strtoupper(substr($LastName,0,1)).substr($LastName,1); $Email = strtolower(str_replace("'","''",$_POST["Email"])); $Title = strtolower(str_replace("'","''",$_POST["Title"])); $Title = strtoupper(substr($Title,0,1)).substr($Title,1); $Company = strtolower(str_replace("'","''",$_POST["Company"])); $Company = strtoupper(substr($Company,0,1)).substr($Company,1); $Address = strtolower(str_replace("'","''",$_POST["Address"])); $Address = strtoupper(substr($Address,0,1)).substr($Address,1); $City = strtolower(str_replace("'","''",$_POST["City"])); $City = strtoupper(substr($City,0,1)).substr($City,1); $State = $_POST["State"]; $Zip = $_POST["Zip"]; $Phone = $_POST["Phone"]; $F = $_POST["F"]; $ProductDesc = $_POST["ProductDesc"]; $Comment = $_POST["Comment"]; if ($GlobalLocation == "Canada"): $SendTo="canadainfo@------.com"; elseif ($GlobalLocation == "Central America"): $SendTo="customer.service@------.com.pa"; elseif ($GlobalLocation == "Europe"): $SendTo="marketing@-----.uk"; elseif ($GlobalLocation == "Mexico"): $SendTo="ventas@------.com.mx"; else: $SendTo="info@------.com"; endif; function dbSet($fields, $source = array()) { $set=''; if (!source) $source = &$_POST; foreach ($fields as $field) { if (isset($source[$field])) { $set.="`$field`='".mysql_real_escape_string($source[$field])."', "; } } return substr($set, 0, -2); } // INSERT INTO DATABASE mysql_select_db("new_contact",$dbc) or die("Could not select new_contact"); $fields = explode(" ", "RequestType ConsumerBusiness GlobalLocation FirstName LastName Email Title Company Address City State Zip Phone F ProductDesc Comment"); $query = "INSERT INTO new_contact SET ".dbSet($fields, $_POST); mysql_query($query); // SETUP EMAIL $Bodycopy = "This information was submitted via the ------.com website and sent to you because of the location identified by the user. <br>If this has reached you in error, please forward this email to info@------.com"; $Bodycopy. "<br>----------------------------------------------------------------------------------------------<br><br>"; if ($RequestType != "") $Bodycopy. "What kind of information do you need? : " .$RequestType. "<br>"; if ($ConsumerBusiness != "") $Bodycopy. "What type of customer or vendor are you? : " .$ConsumerBusiness. "<br>"; if ($GlobalLocation != "") $Bodycopy. "Global Location : " .$GlobalLocation. "<br>"; if ($Company != "") $Bodycopy. "Company : " .$Company. "<br>"; if ($FirstName != "") $Bodycopy. "First Name : " .$FirstName. "<br>"; if ($LastName != "") $Bodycopy. "Last Name : " .$LastName. "<br>"; if ($Title != "") $Bodycopy. "Title : " .$Title. "<br>"; if ($Email != "") $Bodycopy. "Email : " .$Email. "<br>"; if ($Address != "") $Bodycopy. "Address : " .$Address. "<br>"; if ($City != "") $Bodycopy. "City : " .$City. "<br>"; if ($State != "") $Bodycopy. "State : " .$State. "<br>"; if ($Zip != "") $Bodycopy. "Zip/Postal Code : " .$Zip. "<br>"; if ($Phone != "") $Bodycopy. "Phone : " .$Phone. "<br>"; if ($F != "") $Bodycopy. "F : " .$F. "<br>"; if ($ProductDesc != "") $Bodycopy. "UPC or product description : " .$ProductDesc. "<br>"; $Bodycopy. "<br>----------------------------------------------------------------------------------------------<br><br>"; if ($Comment != "") $Bodycopy. "Comments : <br>" .$Comment. "<br>"; $Bodycopy. "<br><br>"; $Bodycopy. $IP = $_SERVER["remote_addr"]; // PROCESS EMAIL // mail server info... $from = $SendTo; $to = "Do Not Reply <donotreply@------>"; $subject = "Website Contact : " . $GlobalLocation; $body = $Bodycopy; $host = "mail.------"; $port = "25"; $username = "donotreply@-------"; $password = "-------"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'port' => $port, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } // MAKE SURE DB CONN IS CLOSED mysql_close($dbc); // REDIRECT TO THANK YOU PAGE header ('Location: /index.php?option'); exit(); } ?> My form values are not posting on my thankyou.php page. I'm sure it's a simple fix. Here's some code from reservation.php . form action="CGI/gdform.php" method="post" enctype="application/x-www-form-urlencoded" name="formres" id="formres"> <input type="hidden" name=" redirect" value="ThankYou.php"> <label><span class="style12">Your Name: <input type="text" name="txtName" id="Name" /> </span></label> ... <p class="style12"><span id="sprytextfield10"> <label>Date of Special Event: <input type="text" name="DateReq" id="DateReq" /> </label> <?php $txtName = $_GET[txtName]; ... $DateReq = $_GET[DateReq]; ?> </form> On my thankyou.php: <body> <?php $txtName = $_POST[txtName]; ... $DateReq = $_POST[DateReq]; ?> and a little lower down... <?php echo $txtName ?> ... <?php echo $DateReq ?> Any reason why the thank you page isn't calling the values? I exhaustively checked it against a working form I have on another site, and the code seems to be, well, identical. Not getting an error, just get empty space where the values should be. This is just a snippet of my code. The php script itself is called test.php and so it calls itself once the form is submitted. I keep having problems retrieving the data back correctly; I am testing in retrieving the data on the same script from the same page before retrieving the POST data from another webpage. If $decimalSum is a variable that assigns a value that is hard-coded then I would be able to retrieve the same value. However, if the value is computed I can not retrieve it unless I click on the "Find" button twice. This is such a strange behavior and I don't know why. Does anyone have any suggested solutions to this? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body> <?php echo '<form enctype="multipart/form-data" method="post" action="test.php">'; echo ' <label for="_firstName">First name : </label>'; echo ' <input type="text" id="_firstName" name ="_firstName">'; echo ' <input type="checkbox" value="1" name="_firstNameChecked"/>'; echo ' <label for="_middleName">Middle name : </label>'; echo ' <input type="text" id="_middleName" name ="_middleName">'; echo ' <input type="checkbox" value="1" name="_middleNameChecked" />'; echo ' <label for="_lastName">Last name : </label>'; echo ' <input type="text" id="_lastName" name ="_lastName">'; echo ' <input type="checkbox" value="1" name="_lastNameChecked" />'; echo '<br />'; echo '<input type="submit" name="Find" value="Find" />'; $firstNameChecked = intval(($_POST['_firstNameChecked'])); $middleNameChecked = intval(($_POST['_middleNameChecked'])); $lastNameChecked = intval(($_POST['_lastNameChecked'])); $decimalSum = (int)((2*2*2)*$firstNameChecked + (2*2)*$middleNameChecked + (2*1)*$lastNameChecked); //$decimalSum = 28; echo '<br />'; echo '$decimalSum = ' . $decimalSum . '<br />'; echo '<input type="hidden" name="_decimalSum" value = "' . $decimalSum . '" />'; $decimalSum2 = ($_POST['_decimalSum']); echo '$decimalSum2 = ' . $decimalSum2 . '<br />'; echo '</form>'; echo '</body>'; echo '</html>'; ?> I have a form that is populating fields based on a database query. I am then trying to update the database based on any changes made in the form and passed through a POST action. The problem I am having is with the block where I declare short variable names for the $_POST variables that will be passed when the user hits the submit button. For each variable declaration I get an error message like this: Quote Encountered error: 8 in mbr_profile_updt_form.php, line 130: Undefined index: email I have tried testing the $_POST variable using the isset function but it apparently is set but empty. What would be a good way to test to see if the user has pressed the submit button before I go into the processing block that is intended to handle those values from the form? Here is where my code is at right now: Code: [Select] if (!isset($_POST)) { throw new Exception('You have not filled the form out completely - please go back' .' and try again.'); } else { //filled in so create short variable names $email=$_POST['email']; $first_name=$_POST['first_name']; $last_name=$_POST['last_name']; hello i have a script and i keep getting an error on php4 i dont get that error only on php5 <?php session_start(); error_reporting(E_ALL); ini_set('display_errors',1); function query_str($params) { $str = ''; foreach ($params as $key => $value) { $str .= (strlen($str) < 1) ? '' : '&'; $str .= $key . '=' . rawurlencode($value); } return ($str); } if($_GET['id']=='1'){ $query=parse_str($_POST); query_str($query); $username=rtrim($username); $password=rtrim($password); // .... continue echo $username.':'.$password.chr(10); } Code: [Select] Warning: parse_str() expects parameter 1 to be string, array given in /var/www/poo/do.php on line 15 Warning: Invalid argument supplied for foreach() in /var/www/poo/do.php on line 7 Notice: Undefined variable: username in /var/www/poo/do.php on line 17 Notice: Undefined variable: password in /var/www/poo/do.php on line 18 the html code is this Code: [Select] <form name="Form_Auth" action="do.php?id=1" method="post" target="_top"> <input name="username" id="txt" value="Nome utente" class="nomeutente"> <input name="password" type="password" maxlength="32" id="pass" value="password" class="password lf"> <input name="bottone" type="submit" class="bottone rf" value="Invia" alt="accedi"> </form> Hi, I am using POST to send the id of a row in a MySQL database, this id should then be used to delete the row from MySQL, this all works fine when I use GET, but as soon as i try and use POST (for security reasons) it deletes another row. Here is the code ($_POST): Code: [Select] <?php $member = $logged['username']; //IFMESSAGES THEN SAY OTHERWISE SAY NO $seemessages = mysql_query("SELECT * FROM `rmail` WHERE `to` = '$member' && `status` = 'unread'"); $howmanymessages = mysql_num_rows($seemessages); $seereadmessages = mysql_query("SELECT * FROM `rmail` WHERE `status` = 'read' && `to` = '$member'"); $howmanyreadmessages = mysql_num_rows($seereadmessages); $totalmessages = $howmanyreadmessages + $howmanymessages; //MENU FOR USING EMAIL VIEWED ON ALL SECTIONS OF R-MAIL echo'<div id="emailmenu"><a href="rmail.php">Home</a>|<a href="rmail.php?inbox">Inbox('.$howmanymessages.'/'.$totalmessages.')</a>|<a href="rmail.php?compose">Compose</a>| </div><br/>'; if(isset($_POST['delete'])){ //DELETE MESSAGE $id = $_POST['delete']; echo $id; $newvalue = mysql_query("SELECT * FROM data"); $newvalue = mysql_fetch_array($newvalue); $newvalue = $newvalue['rmailsent']; $newvalue = $newvalue-1; mysql_query("UPDATE data SET rmailsent = '$newvalue'"); mysql_query("DELETE FROM rmail WHERE `id` = '$id'"); echo "Message has been deleted!"; } else if(isset($_GET['inbox'])){ $username = $logged['username']; //DISPLAY EMAILS FOR USER //WHEN DISPLAYING DISPLAY LINK WITH THE ID TO VIEW THE SPECIFIC MESSAGE $getemail = mysql_query("SELECT * from rmail WHERE `to` = '$username' ORDER BY `id` DESC"); echo' <table border="1"> <tr> <td> <font size="5">Check</font> </td> <td> <font size="5">Status</font></td> <td><font size="5">From</font></td> <td width="500"><font size="5">Subject</font></td> <td><font size="5">Date Sent</font></td> <td><font size="5">Time Sent</font></td> <td><font size="5">Action</font></td> </tr> '; while($email = mysql_fetch_array($getemail)){ $id = $email['id']; if($email['status'] == "unread"){ echo "<tr bgcolor='#666666'>"; }else{ echo "<tr>"; } echo '<td><input type="checkbox" name="'.$email['id'].'checked" class="check"></td>'; echo '<td>'; if($email['status'] == "unread"){ echo '<center><img src="/webimages/unread.gif" alt="Message Unread" width="30" height="25"></center>'; }else if($email['status'] == "read"){ echo '<center><img src="/webimages/read.gif" alt="Message Read" width="30" height="25"><center>'; } echo '</td>'; echo '<td>'.$email['from'].'</td>'; echo '<td><a href="rmail.php?viewmail&id='.$email['id'].'">'.$email['subject'].'</a></td>'; echo '<td>'.$email['date'].'</td>'; echo '<td>'.$email['time'].'</td>'; echo '<td><form action="rmail.php" method="post"> <input type="hidden" value="'.$email['id'].'" name="delete"><input type="image" src="/webimages/delete.png" onclick="return confirm(\'Are you sure you want to Delete?Click Ok to proceed and Delete or Cancel if you do not want to delete!\');"><a href="viewmembers.php?user='.$email['from'].'"><img src="/webimages/eye3.gif" border="0" height="25" width="30"></a></td>'; echo "</font></tr>"; } echo "</table>"; } </html> Here is the code with $_GET (this works but $_POST doesnt): Code: [Select] <?php $member = $logged['username']; //IFMESSAGES THEN SAY OTHERWISE SAY NO $seemessages = mysql_query("SELECT * FROM `rmail` WHERE `to` = '$member' && `status` = 'unread'"); $howmanymessages = mysql_num_rows($seemessages); $seereadmessages = mysql_query("SELECT * FROM `rmail` WHERE `status` = 'read' && `to` = '$member'"); $howmanyreadmessages = mysql_num_rows($seereadmessages); $totalmessages = $howmanyreadmessages + $howmanymessages; //MENU FOR USING EMAIL VIEWED ON ALL SECTIONS OF R-MAIL echo'<div id="emailmenu"><a href="rmail.php">Home</a>|<a href="rmail.php?inbox">Inbox('.$howmanymessages.'/'.$totalmessages.')</a>|<a href="rmail.php?compose">Compose</a>| </div><br/>'; if(isset($_GET['delete'])){ //DELETE MESSAGE $id = $_GET['delete']; echo $id; $newvalue = mysql_query("SELECT * FROM data"); $newvalue = mysql_fetch_array($newvalue); $newvalue = $newvalue['rmailsent']; $newvalue = $newvalue-1; mysql_query("UPDATE data SET rmailsent = '$newvalue'"); mysql_query("DELETE FROM rmail WHERE `id` = '$id'"); echo "Message has been deleted!"; } else if(isset($_GET['inbox'])){ $username = $logged['username']; //DISPLAY EMAILS FOR USER //WHEN DISPLAYING DISPLAY LINK WITH THE ID TO VIEW THE SPECIFIC MESSAGE $getemail = mysql_query("SELECT * from rmail WHERE `to` = '$username' ORDER BY `id` DESC"); echo' <table border="1"> <tr> <td> <font size="5">Check</font> </td> <td> <font size="5">Status</font></td> <td><font size="5">From</font></td> <td width="500"><font size="5">Subject</font></td> <td><font size="5">Date Sent</font></td> <td><font size="5">Time Sent</font></td> <td><font size="5">Action</font></td> </tr> '; while($email = mysql_fetch_array($getemail)){ $id = $email['id']; if($email['status'] == "unread"){ echo "<tr bgcolor='#666666'>"; }else{ echo "<tr>"; } echo '<td><input type="checkbox" name="'.$email['id'].'checked" class="check"></td>'; echo '<td>'; if($email['status'] == "unread"){ echo '<center><img src="/webimages/unread.gif" alt="Message Unread" width="30" height="25"></center>'; }else if($email['status'] == "read"){ echo '<center><img src="/webimages/read.gif" alt="Message Read" width="30" height="25"><center>'; } echo '</td>'; echo '<td>'.$email['from'].'</td>'; echo '<td><a href="rmail.php?viewmail&id='.$email['id'].'">'.$email['subject'].'</a></td>'; echo '<td>'.$email['date'].'</td>'; echo '<td>'.$email['time'].'</td>'; echo '<td><a href="rmail.php?delete='.$email['id'].'">DELETE</a><a href="viewmembers.php?user='.$email['from'].'"><img src="/webimages/eye3.gif" border="0" height="25" width="30"></a></td>'; echo "</font></tr>"; } echo "</table>"; } </html> Any Ideas? Thanks Rhys Hi there. My problem is quite simple, but carries lots of questions of why the hell is this happening. I'm new at PHP but I'm familiar with the syntax, since It's been 3 years since I code in C, 1 in Java and half year in JS (with HTML and CSS of course). I was creating a page where I could validate a HTML form using PHP script, it was going everything allright, until I couldn't use the data that was going to the $_POST array. I tested it on some other file and It was like the server just didn't allowed me to do it so. I searched around on internet and I found the print_r() function, which shows the data as an associative array in $_POST, like this: array(KeyName => ValueName). Check the code and please, help me find why is this happening. I'm brazillian and all I know about english came from netflix, so i'm sorry if I wrote anything wrong. Thanks S&Z
<!DOCTYPE html> So, i need this. I'm making a script for editing lines in a text file. PHP code form form script: $n = 0; $bestand = "../test.txt"; $gegevens = file($bestand); //count lines titel.txt $lines = count(file($bestand)); while($n < $lines) { $items = explode("|", $gegevens[$n]); $titel = $items[0]; $beschrijving = $items[1]; $n=$n+1; echo "<tr> <td><input type=\"text\" class=\"edit\" name=\"titel[".$n."]\" value=\" ".$titel." \" /></td> <td><textarea name=\"beschrijving[".$n."]\">".$beschrijving."</textarea></td> </tr>"; } Code of processing script <?php $n = 1; $bestand = "../test.txt"; $lines = count(file($bestand)); while($n < $lines){ //Set variables $titel = $_POST['titel[$n]']; //Replace 'Enter' for '<br />' $_POST['beschrijving[$n]'] = preg_replace ("#\r?\n#", '<br />', $_POST['beschrijving[$n]']); $beschrijving = $_POST['beschrijving[$n]']; //Write $titel $handle = fopen($bestand, "a"); fwrite($handle, "".$titel."|"); fclose($handle); //Write $beschrijving $handle = fopen($bestand, "a+"); fwrite($handle, "".$beschrijving." "); fclose($handle); $n=$n+1; } ?> De form scripts works fine, no problems. But the processing script give me the next notices: Code: [Select] Notice: Undefined index: titel[$n] in /var/www/NellekeTekent/cms/edit.php on line 10 Notice: Undefined index: beschrijving[$n] in /var/www/NellekeTekent/cms/edit.php on line 13 Notice: Undefined index: titel[$n] in /var/www/NellekeTekent/cms/edit.php on line 10 Notice: Undefined index: titel[$n] in /var/www/NellekeTekent/cms/edit.php on line 10 Notice: Undefined index: titel[$n] in /var/www/NellekeTekent/cms/edit.php on line 10 I gues the problem is '$n' when setting $titel and $beschrijving. But I don't know how to solve it. Can you help me? Hi all, I have been working on this script for over 5 hours, the script used to work but I have recreated some html code in the html form and I think it may have something to do with why the script does not work but I can not see it. Hopefully an extra pair of eyes can help. The I have tested what the $_POST['title'] below echos in the php script and it does carry the value to the php page, but the IF statement does not work. Here it is: html form in a php page: Code: [Select] <form action="testform.php" method="post"> <fieldset style="border:none"> <ul class="controls"> <li> <label for="label">Title</label> <input name="title" id="title" type="text" class="text" maxlength="" value="grumman aa4" /> </li> <li> <label for="label">Aircraft Registration</label> <input name="reg" id="label" type="text" class="text" maxlength="6" value="G-qwea" style="text-transform:uppercase;" /> </li> <li> <input name="Button" type="submit" class="button centered" /> </li> </ul> </fieldset></form> The part of the PHP page that does not work is below. If the php below just says if ($_POST['reg'] == "")... it works but as soon as I put || $_POST['title'] it does not work. I have also tried if ($_POST['reg'] && $_POST['title'] == "")... which DOES work? testform.php <?php if ($_POST['reg'] || $_POST['title'] == "") { $fillinform = "Please fill in all the form to add a listing."; include("saleform.php"); exit(); } ?> I usually hate to post something like this as a first post...I'd like to at least do an into but I"m stumped and I think it's a totally stupid thing I"m not noticing. Anyway, this is the final step in a three step user verification; this is for a staff user to be verified. Anyway, by now they have already verified their email and entered a random code so I"m only worried about actually setting them to verified status in my database so they can start working on blogs etc. Anyway, this form is supposed to find all unverified staff members, and allow an admin to easily just click down the list (one at a time currently) and verify the user (ie. setting their database status to verified_staffUser). The username that is supposed to be verified (or declined and therefore their entry deleted) is supposed to be passed through as $_POST[vnsupUsername]. This is set each time it loops through and prints a new user. The problem is that it's only sending the final username when I click verify/decline on any user :\. I"m not sure why it's doing this. In firebug on firefox it's showing that the user name is set for each one to be properly in the form...but when I click on it (I am having on my machine) the username being worked with echoed..and it's always the last one that was entered into the database. I have no idea why this is happening ..any thoughts? Code: [Select] <?php if(isset($_GET[vnsufac]) || isset($_POST[svnsu]) || isset($_POST[dvnsu])){ // simply prints the back home button echo "<form action=\"http://localhost/~atharp1122/OGirly_Site/ogirly_staff_homepage.php\" method=\"post\">" ."<input type=\"submit\" value=\"Back to Staff Homepage\" style=\"margin-top:10px;\">"; // this will print out the form to verify/deny all new staff user requests that have been email verified $programCheckUVStaff = mysql_query("SELECT username, email, firstname, lastname FROM staffUNAP where verified_staff = '0'"); while($UVStaff = mysql_fetch_assoc($programCheckUVStaff)){ print "<div class=\"newVerifyUserContain\" >"; print "<div class=\"newVerifyUser\" >"; echo "<h3 style=\"text-align: center;\">Would you like to verify this Staff request?</h3>"; echo "<table><tr><td>" ."<img src=\"images/default_icons/di_bunny_rabbit.png\" width=\"56\" height=\"59\" />" ."<ul style=\"padding-left: 100px; padding-bottom: 20px; margin-top: -42px; list-style-type: none;\"><li>" ."{$UVStaff[username]} aka {$UVStaff[firstname]} {$UVStaff[lastname]}</li><li>" ."{$UVStaff[email]}</li></ul></td></tr><tr><td>" ."<form action=\"{$_SERVER[PHP_SELF]}\" method=\"post\">" ."<input type=\"checkbox\" name=\"isadmin\" value=\"1\" style=\"margin-left: 10px;\">Is Admin?" ."<input type=\"hidden\" name=\"vnsupUsername\" value=\"{$UVStaff['username']}\">" ."<input type=\"submit\" name=\"svnsu\" value=\"Verify Staff\" style=\"margin-left: 200px;\">" ."<input type=\"submit\" name=\"dvnsu\" value=\"Decline Request\">"; print "</table>"; print "</div></div>"; } } // verify a staff member if(isset($_POST[svnsu])){ echo "verifying a new user"; echo $_POST[vnsupUsername]; } ?> I'm trying firstly to output hidden fields based on the values of the $_POST variable. Then after that I want to output the values again in a unordered list. I'm using the following code: while (list($key, $val) = each($_POST)) { if ($key != 'Submit') { echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />'; } } echo '<ul>'; while (list($key, $val) = each($_POST)) { if ($key != 'Submit') { echo '<li><strong>' . $key . '</strong>: <span class="highlight-219ddb">' . $val . '</span></li>'; } } echo '</ul>'; However the <ul> appears to be blank? Can I only use the list() function once on a particular variable? Why doesn't this code work... Code: [Select] // Initialize variables. $form_value = ''; $form_value = $_POST['form_value']; I get this error... Quote Notice: Undefined index: form_value Thanks, Debbie I have a problem that occurred only recently, apparently by some change my webhost made on the server. Some time ago I wrote a script that simulates a Poedit-type editor. The script has about 1500 textareas (the translation fields) with unique names, dynamically generated. All worked fine. Now suddenly I get errors (see below) when I use more than 1000 textareas. It is not a problem of $_POST size, if happens also with empty textareas. I will show here a simple php test file that I called testta.php, which creates the same error as my much more complicated real script: Code: [Select] <?php if(isset($_POST['test'])) { echo 'The textareas were posted successfully!<br>'; } $max = 1500; echo '<form action="testta.php" method="POST">'; echo '<input type="submit" name="test" value="Submit"><br>'; for($i=0; $i < $max; $i++) { echo '<textarea name="test'.$i.'">name is test'.$i.'</textarea><br>'; } echo '</form>'; ?> The error message generated in the browser: 500 Server Error: A misconfiguration on the server caused a hiccup. Check the server logs, fix the problem, then try again. From the Apache log file: [Sat Apr 28 12:47:48 2012] [error] [client 93.172.175.50] Premature end of script headers: testta.php, referer: http://****/*****/testta.php (stars added for privacy) When $max is set to a number < 1000 it works. On the web I have only found answers that deal with max size of posts, but as I mentioned that is not my case. My webhost can't help me out either. Until last Friday all worked fine. Does anyone know what server setting could create this problem? Thanks in advance, Kathy I want to post some form identifyer when I hit submit, so that I can use this in an SQL query. Previously I used the below code and would retrieve either page1.php or page2.php etc from $_POST['subject']); Code: [Select] <td> <select name="subject" id="subject" onchange="gotourl(this.value)"> <option value="" >Please Select</option> <option value="page1.php" >page1</option> <option value="page2.php">page2</option> <option value="page3.php">page3</option> </select> </td> will this work? Code: [Select] <form id="form1" name="form1" value="tableName" method="post" action=""> $_POST['form1']) returns tableName...... Thanks Hi guys, running through this tutorial at the moment: http://www.tizag.com/phpT/forms.php I seem to keep having problems with the $_POST variable. Is that obsolete syntax now? Here's the part I get an error on: <html> <body> <?php $quantity=$_POST['quantity']; $item=$_POST['item']; echo "You ordered".$quantity."".$item.".<br/>."; echo "Thank you for ordering from Boombaby art supppplies!"; ?> </body> </html> Here's the error: ( ! ) Notice: Undefined index: quantity in C:\wamp\www\process.php on line 4 Call Stack # Time Memory Function Location 1 0.0009 363936 {main}( ) ..\process.php:0 ( ! ) Notice: Undefined index: item in C:\wamp\www\process.php on line 5 Call Stack # Time Memory Function Location 1 0.0009 363936 {main}( ) ..\process.php:0 You ordered. .Thank you for ordering from Boombaby art supppplies! Any help would be appreciated. I tried googling but everything didn't seem to answer my question or was too confusing. Thanks. Hi guys, I have a form using radio buttons. For the radio button, lets just say i have the id name as 'rim' + number eg; rim0, rim1, rim2.... When i post the data to another file to execute the data collected, naturally i would use the: Code: [Select] $rim0=$_POST['rim0']; $rim1=$_POST['rim1']; .... $rim10=$_POST['rim10']; i tried to shorten this process using this method: Code: [Select] //$q is part of the post variable. for($x = 0; $x < count($q); $x++){ $rim[]=$_POST['"rim"."$x"']; } But i get this error Code: [Select] Notice: Undefined index: "rim"."$x" in D:\Apache Software Foundation\Apache2.2\htdocs\.....\#####.php on line 20 Notice: Undefined index: "rim"."$x" in D:\Apache Software Foundation\Apache2.2\htdocs\.....\#####.php on line 20 Notice: Undefined index: "rim"."$x" in D:\Apache Software Foundation\Apache2.2\htdocs\.....\#####.php on line 20 Notice: Undefined index: "rim"."$x" in D:\Apache Software Foundation\Apache2.2\htdocs\.....\#####.php on line 20 Notice: Undefined index: "rim"."$x" in D:\Apache Software Foundation\Apache2.2\htdocs\.....\#####.php on line 20 Notice: Undefined index: "rim"."$x" in D:\Apache Software Foundation\Apache2.2\htdocs\.....\#####.php on line 20 Notice: Undefined index: "rim"."$x" in D:\Apache Software Foundation\Apache2.2\htdocs\.....\#####.php on line 20 Notice: Undefined index: "rim"."$x" in D:\Apache Software Foundation\Apache2.2\htdocs\.....\#####.php on line 20 Notice: Undefined index: "rim"."$x" in D:\Apache Software Foundation\Apache2.2\htdocs\.....\#####.php on line 20 Notice: Undefined index: "rim"."$x" in D:\Apache Software Foundation\Apache2.2\htdocs\.....\#####.php on line 20 Is there something wrong with my POST syntax? Hello, My script here is not sending POST vars from form to script. I can't figure it out. Form: Code: [Select] <form action="train2.php" method="POST"> <tr> <td colspan="4"><center><img src="pic/toppage16.gif" /></center></td> </tr> <TR> <TD><FONT COLOR="white">Reassign Miners</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD> <TD align=middle><FONT COLOR="white"><INPUT size="6" maxlength="8" value="0" name="miner>"</FONT></TD> </TR> <TR> <TD><FONT COLOR="white">Reassign Normal Attackers</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD> <TD align=middle><FONT COLOR="white"><INPUT size="6" maxlength="8" value="0" name="atsold"></FONT></TD> </TR> <TR> <TD><FONT COLOR="white">Reassign Normal Defenders</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD> <TD align=middle><FONT COLOR="white"><INPUT size=6 maxlength=8 value=0 name="defsold"></FONT></TD> </TR> <TR> <TD><FONT COLOR="white">Reassign Covert Agents</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD> <TD align=middle><FONT COLOR="white"><INPUT size=6 maxlength=8 value=0 name="spy"></FONT></TD> </TR> <TR> <TD><FONT COLOR="white">Anti Covert Agents</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD><TD align=middle><FONT COLOR="white"><INPUT size="6" maxlength=8 value=0 name="spykiller"></FONT></TD></TR> <TR> <TD align=middle colSpan=3><FONT COLOR="white"><INPUT type="submit" value="UnTrain!" name="untrain"> </FONT> </TD> </form> Code: [Select] <?php if(isset($_POST['untrain'])){ die($_POST['miner']); $miners = securevar($_POST['miner']); $nattackers = securevar($_POST['atsold']); $ndefenders = securevar($_POST['defsold']); $covertunits = securevar($_POST['spy']); $anticovertunits = securevar($_POST['spykiller']); $totalunits+=$miners; $totalunits+=$nattackers; $totalunits+=$ndefenders; $totalunits+=$covertunits; $totalunits+=$anticovertunits; if($totalunits>=1){ $q = "UPDATE `accountinfo_db` SET `miners_1` = `miners_1`-'$miner', `attackers_1` = `attackers_1`-'$natta', `defenders_1` = `defenders_1`-'$ndefe', `covertagents` = `covertagents`-'$cover', `anticovertagents` = `anticovertagents`+'$antic', `untrainedunits` = `untrainedunits`+'$totalunits' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); if(isset($res)){ header("Location: train.php?strmsg=".$totalunits."Troops Untrained! For 0 Naquadah."); } }else{ header("Location: train.php?strmsg=You must enter atleast 1 troop to be un-trained!"); } } ?> when I die($_GET['miner'); nothing is outputed even tho I submited the data. Thank you, Brian ok am workin on this script its a points market for a text based game but my money is not taking the amount of the players i points on the market ... just say i post 10 points for $29.000.000 ... and when the player buys the points it takes the money from that user and give the user points but .... when the user buy the points it dont give the user the money it give $290 ?? not sure is its my SQL av post that to Code: [Select] <?php include 'header.php'; $_POST['buypoints'] = abs(intval($_POST['buypoints']));{ $result = mysql_query("SELECT * FROM `pointsmarket` WHERE `id`='".$_POST['points_id']."'"); $worked = mysql_fetch_array($result); $price = $worked['price']; $amount = $worked['amount']; $totalcost = $price * prettynum($_POST['amount']); $newpointsinmarket = $amount - prettynum($_POST['amount']); $user_points = new User($worked['owner']); if ($worked['owner'] == $user_class->id) { echo Message("You have taken ".$_POST['amount']." points off the market."); $newpoints = $user_class->points + $_POST['amount'];; $result = mysql_query("UPDATE `grpgusers` SET `points` = '".$newpoints."' WHERE `id`='".$user_class->id."'"); $user_class = new User($_SESSION['id']); if ($newpointsinmarket == 0){ $result = mysql_query("DELETE FROM `pointsmarket` WHERE `id`='".$worked['id']."'"); } else { $result = mysql_query("UPDATE `pointsmarket` SET `amount` = '".$newpointsinmarket."' WHERE `id`='".$worked['id']."'"); } include 'footer.php'; die(); } $_POST['amount'] = abs(intval($_POST['amount'])); $_POST['points_id'] = abs(intval($_POST['points_id']));{ } $_POST['amount'] = abs(intval($_POST['amount'])); $_POST['points_id'] = abs(intval($_POST['points_id']));{ } if ($totalcost > prettynum($user_class->money)){ echo Message("You don't have enough money."); } if($_POST['amount'] >= 1 && $_POST['amount'] <= $amount && $totalcost <= $user_class->money){ echo Message("You have bought ".$_POST['amount']." points for $".$totalcost); $newpoints = $user_class->points + $_POST['amount']; $newmoney = $user_class->money - $totalcost; $result = mysql_query("UPDATE `grpgusers` SET `money` = '".$newmoney."', `points` = '".$newpoints."' WHERE `id`='".$user_class->id."'"); $newmoney = $user_points->money + $totalcost; $result = mysql_query("UPDATE `grpgusers` SET `money` = '".$newmoney."' WHERE `id`='".$user_points->id."'"); $user_class = new User($_SESSION['id']); if ($newpointsinmarket == 0){ $result = mysql_query("DELETE FROM `pointsmarket` WHERE `id`='".$worked['id']."'"); } else { $result = mysql_query("UPDATE `pointsmarket` SET `amount` = '".$newpointsinmarket."' WHERE `id`='".$worked['id']."'"); } } } $_POST['addpoints'] = abs(intval($_POST['addpoints'])); $_POST['id'] = abs(intval($_POST['id']));{ } if($_POST['amount'] < 1){ } if($_POST['price'] < 1){ } if ($_POST['amount'] >= 1 && prettynum($_POST['amount']) <= $user_class->points && $_POST['price'] >= 1){ echo Message("You have added ".$_POST['amount']." points to the market a price of $".$_POST['price']." per point."); $result= mysql_query("INSERT INTO `pointsmarket` (owner, amount, price)"."VALUES ('$user_class->id', '$_POST[amount]', '$_POST[price]')"); $newpoints = $user_class->points - $_POST['amount']; $result = mysql_query("UPDATE `grpgusers` SET `points` = '".$newpoints."' WHERE `id`='".$user_class->id."'"); $user_class = new User($_SESSION['id']); } ?> <link href="style.css" rel="stylesheet" type="text/css" /> <tr><td class="contenthead">Point Market</td></tr> <tr><td align="center" class="contentcontent"> <p> </p> <p><strong>You need to be a Respected Warrior to add points to the market</strong><br> Use this form to add points to the points market.</p> <p><strong>Bank Account[<? echo prettynum($user_class->bank) ?>]</strong><strong></strong><br /> <strong><a href="pointmarket.php">[Refresh</a>]</strong></p> <form method='post'> <table align="center"> <tr> <td>Amount of points</td><td> <input name='amount' type='text' class="areatest" value='0' size='10' maxlength='20'></td> </tr> <tr> <td>Price per point</td><td>$<input name='price' type='text' class="areatest" value="0" size='10' maxlength='20'></td> <tr><td align="center" colspan="2"><input name='addpoints' type='submit' class="buttong" value='Add Points'></form></td> </tr></table> </td></tr> <tr><td class="contentcontent"> <?php $result = mysql_query("SELECT * FROM `pointsmarket` ORDER BY `price` DESC"); while($line = mysql_fetch_array($result, MYSQL_ASSOC)) { $user_points = new User($line['owner']); if ($user_points->id == $user_class->id){ $submittext = "Remove"; } else { $submittext = "Buy"; } echo "<form method='post'>"; echo $user_points->formattedname." - ".$line['amount']." points for ".prettynum($line['price'],1)." per point <input type='text' name='amount' size='3' maxlength='20' value='".prettynum($line['amount'])."'><input type='hidden' name='points_id' value='".$line['id']."'><input type='submit' name='buypoints' value='".$submittext."'></form><br>"; } ?> </td></tr> <?php include 'footer.php'; ?> SQL Code: [Select] CREATE TABLE IF NOT EXISTS `pointsmarket` ( `owner` int(10) NOT NULL default '0', `amount` text NOT NULL, `price` text NOT NULL, `id` int(10) NOT NULL auto_increment, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=81 ; |