Gibbs Posted January 18, 2007 Share Posted January 18, 2007 I'm really confused. To test that i'm getting the right information from the forms i've printed them...Any help would be great!This is how i'm getting the info:[code=php:0]include("include/session.php"); $userx = $session->username; // Get the username logged in$perform = $_GET['perform']; // Get the perform URL$table = "bio"; // The table to read and write to// Get the employee details (if they submit them)$firstname = $_POST[bio_fname];$secondname = $_POST['bio_sname'];$age = $_POST['bio_age'];$gender = $_POST['bio_gender'];$birth = $_POST['bio_birth'];$residence = $_POST['bio_residence'];$bio = $_POST['bio_bio'];$education = $_POST['bio_education'];$training = $_POST['bio_training'];[/code]This is the form etc...[code=php:0]if ($perform==add) {echo "<p>Welcome $userx. Please submit accurate and correct information only. If you make any mistakes or your details change you may update your entry at any time. <br>Thank you.<br></p><table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><form action=\"vtxemp.php?perform=submit1337\" method=\"post\"><tr><td width=\"115\" height=\"25\"><p align=\"right\">First name: </p></td><td width=\"385\"><input name=\"bio_fname\" type=\"text\" class=\"textpm\"></td></tr><tr><td height=\"25\"><p align=\"right\">Second Name: </p></td><td><input name=\"bio_sname\" type=\"text\" class=\"textpm\"></td></tr><tr><td height=\"25\"><p align=\"right\">Age: </p></td><td><input name=\"bio_age\" type=\"text\" class=\"textpm\" size=\"2\" maxlength=\"2\"></td></tr><tr><td height=\"25\"><p align=\"right\">Gender: </p></td><td><select name=\"bio_gender\" class=\"dropdownl\"><option value=\"Male\">Male</option><option value=\"Female\">Female</option></select></td></tr><tr><td height=\"25\"><p align=\"right\">Place of Birth: </p></td><td><input name=\"bio_birth\" type=\"text\" class=\"textpm\"></td></tr><tr><td height=\"25\"><p align=\"right\">Current Residence: </p></td><td><input name=\"bio_residence\" type=\"text\" class=\"textpm\"></td></tr><tr><td valign=\"top\"><p align=\"right\">Employee Bio: </p></td><td><label><textarea name=\"bio_bio\" cols=\"60\" rows=\"10\" class=\"textpm\"></textarea></label></td></tr><tr><td valign=\"top\"><p align=\"right\">Education: </p></td><td><textarea name=\"bio_education\" cols=\"60\" rows=\"4\" class=\"textpm\"></textarea></td></tr><tr><td valign=\"top\"><p align=\"right\">Training: </p></td><td><textarea name=\"bio_training\" cols=\"60\" rows=\"4\" class=\"textpm\"></textarea></td></tr><tr><td valign=\"top\"> </td><td><label><input type=\"submit\" name=\"Submit\" value=\"Submit Entry\"></label></td></tr></form></table>";}if ($perform==submit1337){echo $firstname or die("First name not entered");echo $secondname or die("Second name not entered");echo $age or die("Age not entered");echo $gender or die("Gender not entered");echo $birth or die("Place of Birth not entered");echo $residence or die("Current Residence");echo $bio or die("Employee Biography not entered");echo $education or die("Education details not entered");echo $training or die("Training details not entered");//$create = "INSERT INTO $table (firstName, secondName, age, gender, placeBirth, cResidence, bio, education, training, username)//VALUES ('$firstname','$secondname','$age','$gender','$birth','$residence', '$bio', '$education', '$training')";//$create2 = mysql_query($create) or die("Database Entry Failed");//echo("<br><br>Thank you. Your details have been submitted to the Vortex Network Employee Database");}[/code]I'm so confused as to whats going wrong.... Please help!Thank you :) Quote Link to comment Share on other sites More sharing options...
SharkBait Posted January 18, 2007 Share Posted January 18, 2007 [code]should it not read:[code]<?phpif($perform == "add") { ...}?>[/code]and [code]<?phpif($perform == "submit1337") { ...}?>[/code]?What part is being returned as numbers and not as strings?[/code] Quote Link to comment Share on other sites More sharing options...
Gibbs Posted January 18, 2007 Author Share Posted January 18, 2007 $perform==submit1337 etc work. These are being returned as the number 1 after submitting the form...[code]$firstname = $_POST[bio_fname];$secondname = $_POST['bio_sname'];$age = $_POST['bio_age'];$gender = $_POST['bio_gender'];$birth = $_POST['bio_birth'];$residence = $_POST['bio_residence'];$bio = $_POST['bio_bio'];$education = $_POST['bio_education'];$training = $_POST['bio_training'];[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 18, 2007 Share Posted January 18, 2007 add this ?><pre><?print_r($_POST); ?></pre><?before here: $firstname = $_POST['bio_fname'];And tell me what it prints. Quote Link to comment Share on other sites More sharing options...
Gibbs Posted January 18, 2007 Author Share Posted January 18, 2007 [quote author=jesirose link=topic=123041.msg508204#msg508204 date=1169162128]add this ?><pre><?print_r($_POST); ?></pre><?before here: $firstname = $_POST['bio_fname'];And tell me what it prints.[/quote]It prints "Array ( )"Edit: I'm using a lot of includes on this page. Could they be conflicting (although everything else is working...)? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 I mean after you hit submit. Quote Link to comment Share on other sites More sharing options...
Gibbs Posted January 19, 2007 Author Share Posted January 19, 2007 Sorry still new to this.[quote]Array ( [bio_fname] => Name [bio_sname] => Name [bio_age] => 32 [bio_gender] => Male [bio_birth] => London [bio_residence] => Devon [bio_bio] => TEST [bio_education] => TEST [bio_training] => TEST [Submit] => Submit Entry )[/quote]Looks like that worked...What can I do with this info, or what does it indicate? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 19, 2007 Share Posted January 19, 2007 Your problem is in this section of code:[code]<?phpecho $firstname or die("First name not entered");echo $secondname or die("Second name not entered");echo $age or die("Age not entered");echo $gender or die("Gender not entered");echo $birth or die("Place of Birth not entered");echo $residence or die("Current Residence");echo $bio or die("Employee Biography not entered");echo $education or die("Education details not entered");echo $training or die("Training details not entered");?>[/code]That is not the correct way of doing this check. Remove the "or die" clauses.Ken Quote Link to comment Share on other sites More sharing options...
Gibbs Posted January 19, 2007 Author Share Posted January 19, 2007 Grrr. It's always something stupidly easy I get headaches over.Thanks for the help!That print_r($_POST); is very useful, will be using it a lot in the future.Thanks again everything is working :) Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 19, 2007 Share Posted January 19, 2007 Just a quick note. if you output [nobbc]"<pre></pre>"[/nobbc] tags before and after the "print_r", the output is much easier to read.[code]<?phpecho '<pre>' . print_r($_POST,true) . '</pre>';?>[/code]I usually put it into a function, so i can pass it any variable I want to see dumped:[code]<?phpfunction dumpvar($var,$str=''){ if (!empty($var)) echo "<pre>$str " . print_r($var,true) . '</pre>';}dumpvar($_POST,'$_POST');dumpvar($_SESSION,'$_SESSION');?>[/code]Ken Quote Link to comment 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.