Jump to content

Mysql W/ Php


EmperorZenos

Recommended Posts

I'm trying to make a feature that adds data to a table, the code is:

<div style="border:1px solid">ZAX Data Input:<br />Name: <input type="text" name="ZAXName" /> ID: <input type="text" name="ZAXid" /> <br />Content:<br /><textarea name="ZAXContent" rows="10" col="20" /><br /></textarea><input type="submit" name="ZAXBtn" /><br /><?php if ($_POST['ZAXBtn']) {$ZAXID=$_POST['ZAXid'];$ZAXNAME=$_POST['ZAXName'];$ZAXCONTENT=$_POST['ZAXContent'];$sql = " INSERT INTO `a7053602_forumd`.`ZAX` (`id` ,`name` ,`content`)VALUES (\'" . $ZAXID . "\', \'" . $ZAXNAME . "\', \'" . $ZAXCONTENT . "\') ";if (!mysql_query($sql,$con)) {die('Error! ' . mysql_error());}echo "Data added.";?></div>

Note: the input tags, submit button, and textarea are wrapped in <form> tags from earlier in the page. But, if it matters, which I feel that it does for some reason, it is the same <form> tags I used to wrap around a login feature to access this feature.Anywho, for the problem.I get redirected to my login portion and no data is added. I got the SQL portion (and modified it some bits by myself) from PhpMyAdmin after seeing if I can Insert data into the table. Any help?

Link to comment
Share on other sites

Er, I think the problem is my technique for Inserting the data.I'm using the same premise on another page, this:

$name = $_POST['title'];$content = $_POST['content'];if ($_POST['Douser']) {$sql = "INSERT INTO `a8949742_sm`.`Kestral` (`id` ,`name` ,`content`)VALUES (NULL , '$name', '$content')";if (!$sql) {	die('Invalid query: ' . mysql_error());}else{mysql_query($sql);}

The form tag's action is pointing towards the page it is on. For something like this, should I make a new page with this code that is pointed to by the form?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...