Jump to content

Data not going to db?


eduard

Recommended Posts

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

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?
  • Like 1
Link to comment
Share on other sites

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

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

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

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 :glare: 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 :glare: no bull###### no one going to help you in this topic, this is the last reply good :Pleased: goodluck you can do it :good:

Link to comment
Share on other sites

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

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 :glare: 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 :glare: no bull###### no one going to help you in this topic, this is the last reply good :Pleased: goodluck you can do it :good:
:facepalm: 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 & ID
id="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 by thescientist
Link to comment
Share on other sites

??? 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

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 by eduardlid
Link to comment
Share on other sites

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!
:lol:
Link to comment
Share on other sites

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

Guest
This topic is now closed to further replies.
×
×
  • Create New...