eduard Posted April 23, 2012 Share Posted April 23, 2012 Why do the data filled im my html form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html lang='en' xml:lang='en'xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>database</title></head><body><form action="insert.php" method="post"><label for="Site_Name">Site_Name:</label><input type="text" name="Site_Name" id="Site_Name"/><label for="Site_URL">Site_URL:</label><input type="text" name="Site_URL" id="Site_URL"/><label for="Description">Description:</label><input type="text" name="Description" id="Description"/><input type="submit" value="Add Link"/></form></body></html> Not go to my db in phpmyadmin: <?php $con = mysql_connect("localhost","root","usbw") or die(mysql_error()); echo "Connected to MySQL";mysql_select_db("website")or die(mysql_error());echo "Connected to Database";$var1=$_POST['site_name'];$var2=$_POST['site_URL'];$var3=$_POST['description'];$sql="INSERT INTO links (Site_Name, Site_URL, Description)VALUES('$var1','$var2','$var3 ')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added";mysql_close($con);?> Link to comment Share on other sites More sharing options...
justsomeguy Posted April 23, 2012 Share Posted April 23, 2012 The names in $_POST need to be case-sensitive. Link to comment Share on other sites More sharing options...
eduard Posted April 23, 2012 Author Share Posted April 23, 2012 The names in $_POST need to be case-sensitive. Thanks very much! Link to comment Share on other sites More sharing options...
boen_robot Posted April 24, 2012 Share Posted April 24, 2012 Thanks very much!WAIT! I've heard THAT one before... did you actually fixed your code here? Is it working? Did you understood why it didn't previously work? 1 Link to comment Share on other sites More sharing options...
eduard Posted April 24, 2012 Author Share Posted April 24, 2012 WAIT! I've heard THAT one before... did you actually fixed your code here? Is it working? Did you understood why it didn't previously work? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html lang='en' xml:lang='en' xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>database</title></head><body><form action="insert.php" method="POST"><label for="Site_Name">Site_Name:</label><input type="text" name="Site_Name" id="Site_Name"/><label for="Site_URL">Site_URL:</label><input type="text" name="Site_URL" id="Site_URL"/><label for="Description">Description:</label><input type="text" name="Description" id="Description"/><input type="submit" value="Add Link"/></form></body></html> Link to comment Share on other sites More sharing options...
boen_robot Posted April 24, 2012 Share Posted April 24, 2012 That's not an answer... especially seeing that this is just your original HTML form, without any modifications to it. Link to comment Share on other sites More sharing options...
eduard Posted April 25, 2012 Author Share Posted April 25, 2012 That's not an answer... especially seeing that this is just your original HTML form, without any modifications to it. No, it´s my modified html form (now: POST was: post!) Link to comment Share on other sites More sharing options...
dsonesuk Posted April 25, 2012 Share Posted April 25, 2012 OMG! its nothing to do with method="post" that is fine! ITS TO DO WITH THE NAME USED WITH INPUTS COMPARED TO NAME USED IN $_POST LOOK! Link to comment Share on other sites More sharing options...
dsonesuk Posted April 25, 2012 Share Posted April 25, 2012 Even Forest Gump knew to eat the the god damn chocolates in his mouth, not up his A@#E. 3 Link to comment Share on other sites More sharing options...
divinedesigns1 Posted April 25, 2012 Share Posted April 25, 2012 Pay attention im only going to do this once, and no one else reply to this post after this, if he cant figure out this after i take my time to do this then hes just not using his brains compare the three, your form names, your php variables and your insert into links names. lets start with the form name FORM NAMES & ID id="Site_Name" name="Site_Name"id="Site_URL" name="Site_URL"id="Description" name="Description" PHP Names$var1 = $_POST['site_name'];$var2 = $_POST['site_url'];$var3 = $_POST['description']; INSERT NAMESINSERT INTO links (Site_Name, Site_URL, Description); Here is a tip everything need to match up or nothing will work, now fix the dam thing, no bullshyt get to it, read it carefully, spell it carefully, match it up carefully even if you have to do it word by word do it no bull###### no one going to help you in this topic, this is the last reply good goodluck you can do it Link to comment Share on other sites More sharing options...
eduard Posted April 25, 2012 Author Share Posted April 25, 2012 Even Forest Gump knew to eat the the god damn chocolates in his mouth, not up his A@#E. Very strange (see post 3)! But I have understood it wrong! P. s. Forrest Gump- I liked that movie, nice woman (I have forgotten her name!) Link to comment Share on other sites More sharing options...
thescientist Posted April 25, 2012 Share Posted April 25, 2012 (edited) Pay attention im only going to do this once, and no one else reply to this post after this, if he cant figure out this after i take my time to do this then hes just not using his brains compare the three, your form names, your php variables and your insert into links names. lets start with the form name FORM NAMES & ID id="Site_Name" name="Site_Name"id="Site_URL" name="Site_URL"id="Description" name="Description" PHP Names$var1 = $_POST['site_name'];$var2 = $_POST['site_url'];$var3 = $_POST['description']; INSERT NAMESINSERT INTO links (Site_Name, Site_URL, Description); Here is a tip everything need to match up or nothing will work, now fix the dam thing, no bullshyt get to it, read it carefully, spell it carefully, match it up carefully even if you have to do it word by word do it no bull###### no one going to help you in this topic, this is the last reply good goodluck you can do it Ugh, you have that wrong, and you're just going confuse the poor man even more. what you define as a name in the HTML, is what is populated in $_POST so, your example's won't work. and none of that has anything to do with the DB schema and what the column names are (I'm not sure what you were trying to do with the INSERT statement, maybe you meant to use the variable names?). So, to clarify, using your example: FORM NAMES & IDid="name" name="Site_Name"id="url" name="Site_URL"id="desc" name="Description" PHP Names //must match form "name" attribute$var1 = $_POST['Site_Name'];$var2 = $_POST['Site_Url'];$var3 = $_POST['Description']; INSERT NAMES //there's no reason the column name's have to match the form namesINSERT INTO links ($var1, $var2, $var3) Edited April 25, 2012 by thescientist Link to comment Share on other sites More sharing options...
divinedesigns1 Posted April 25, 2012 Share Posted April 25, 2012 ok Link to comment Share on other sites More sharing options...
dsonesuk Posted April 25, 2012 Share Posted April 25, 2012 ??? What the ###### is going on here? Its like a epidemic id="name" name="Site_Name"id="url" name="Site_URL"id="desc" name="Description" YES! //must match form "name" attribute$var1 = $_POST['Site_Name'];$var2 = $_POST['Site_Url'];$var3 = $_POST['Description']; YES! LASTLY taken from edu whatever original code where apparently he used same names for column names $sql="INSERT INTO links (Site_Name, Site_URL, Description)VALUES('$var1','$var2','$var3 ')"; YES! I'm off the get inoculated, cause i definitely don't want this Link to comment Share on other sites More sharing options...
eduard Posted April 25, 2012 Author Share Posted April 25, 2012 (edited) I sent you a wrong file: (modified 24 4 2012) <?php $con = mysql_connect("localhost","root","usbw") or die(mysql_error()); echo "Connected to MySQL"; mysql_select_db("website")or die(mysql_error());echo "Connected to Database"; $var1=$_POST['Site_Name'];$var2=$_POST['Site_URL'];$var3=$_POST['Description']; $sql="INSERT INTO links (Site_Name, Site_URL, Description)VALUES('$var1','$var2','$var3 ')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added"; mysql_close($con); ?> So. thank you for all ´nice´ comments, but you are 2 days too late! Edited April 25, 2012 by eduardlid Link to comment Share on other sites More sharing options...
dsonesuk Posted April 25, 2012 Share Posted April 25, 2012 Phorrgh! can you smell that! it's not dog, and its definitely not horse, ahhh i know what it is, of course... it's B#LLS#!T Link to comment Share on other sites More sharing options...
thescientist Posted April 25, 2012 Share Posted April 25, 2012 I sent you a wrong file: (modified 24 4 2012) <?php $con = mysql_connect("localhost","root","usbw") or die(mysql_error()); echo "Connected to MySQL"; mysql_select_db("website")or die(mysql_error());echo "Connected to Database"; $var1=$_POST['Site_Name'];$var2=$_POST['Site_URL'];$var3=$_POST['Description']; $sql="INSERT INTO links (Site_Name, Site_URL, Description)VALUES('$var1','$var2','$var3 ')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added"; mysql_close($con); ?> So. thank you for all ´nice´ comments, but you are 2 days too late! Link to comment Share on other sites More sharing options...
boen_robot Posted April 26, 2012 Share Posted April 26, 2012 I guess we're done here then...In the future, instead of simply saying "thanks" (which is nice, don't get me wrong...), also post your working code, so that we can see you really got the point.<< Locked >> Link to comment Share on other sites More sharing options...
Recommended Posts