aebstract Posted January 17, 2008 Share Posted January 17, 2008 Hey guys, been awhile since I have been around these parts, but I am having a little trouble. I got a form with two simple inputs. I put a check at the top of my page to see if the field has information entered or not. Well it is returning false when it has information and when it doesn't. Here is what I have: (file - account2.php) <?php session_start(); header("Cache-control: private"); if (isset ($_POST['submit'])) { $problem = FALSE; if (empty ($_POST['plantloc'])) { $problem = TRUE; $error .= 'Must enter a plant location<br />'; } mysql_connect("*","*","*"); mysql_select_db("*"); if (!$problem) { $plantloc = $_POST['plantloc']; $length = 6; $password = ""; $possible = "0123456789bcdfghjkmnpqrstvwxyz"; $i = 0; while ($i < $length) { $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); if (!strstr($password, $char)) { $password .= $char; $i++; } } $password2 = md5($_POST['password1']); $address = $_POST['address']; $result = MYSQL_QUERY("INSERT INTO plants (plantloc,password,address)". "VALUES ('$plantloc, '$password2', '$address,')"); $sendmail = " $password2 "; mail ('tcantwell@berryequipment.net', 'Thank You', $sendmail, 'From: aebstract@gmail.com'); } else { $content .= "$error"; } } ?> and the form area: <?php $content .= '<form action="account2.php?menu=create" method="post"> <br /> Plant Location: <br /><input type="text" maxlength="100" class="textfield" name="username" size="40" value="' . $_POST[plantloc] . '" /><br /><br /> Address:<br /> <textarea cols="50" rows="4" name="address" value="' . $_POST[address] . '"></textarea> <br /><br /> <input type="submit" name="submit" value="submit" class="textfield" /></form>'; echo "$content"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/86486-solved-form-isnt-passing-my-variable/ Share on other sites More sharing options...
trq Posted January 17, 2008 Share Posted January 17, 2008 I don't see any form element named plantloc. Quote Link to comment https://forums.phpfreaks.com/topic/86486-solved-form-isnt-passing-my-variable/#findComment-441904 Share on other sites More sharing options...
aebstract Posted January 17, 2008 Author Share Posted January 17, 2008 ? You didn't see this line? Plant Location: <br /><input type="text" maxlength="100" class="textfield" name="username" size="40" value="' . $_POST[plantloc] . '" /><br /><br /> Quote Link to comment https://forums.phpfreaks.com/topic/86486-solved-form-isnt-passing-my-variable/#findComment-441909 Share on other sites More sharing options...
trq Posted January 17, 2008 Share Posted January 17, 2008 Yes, and that form element is named username. Quote Link to comment https://forums.phpfreaks.com/topic/86486-solved-form-isnt-passing-my-variable/#findComment-441911 Share on other sites More sharing options...
aebstract Posted January 17, 2008 Author Share Posted January 17, 2008 thanks sorry I looked right past that. Quote Link to comment https://forums.phpfreaks.com/topic/86486-solved-form-isnt-passing-my-variable/#findComment-441913 Share on other sites More sharing options...
Stooney Posted January 17, 2008 Share Posted January 17, 2008 I noticed you seem to be missing a '}' <?php if (isset ($_POST['submit'])) { $problem = FALSE; } //This was missing if (empty ($_POST['plantloc'])) { $problem = TRUE; $error .= 'Must enter a plant location<br />'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/86486-solved-form-isnt-passing-my-variable/#findComment-441915 Share on other sites More sharing options...
mars_rahul Posted January 17, 2008 Share Posted January 17, 2008 Actually when fiile transfers data from one page to another page 'name' is used to retrieve the value. So, it will work, instead of $_POST['plantloc'] ==> use =>>&_POST['username']; If any problem Then PM me. Reply it works. Quote Link to comment https://forums.phpfreaks.com/topic/86486-solved-form-isnt-passing-my-variable/#findComment-441939 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.