EmperorZenos Posted July 20, 2009 Share Posted July 20, 2009 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 More sharing options...
NurAzije Posted July 20, 2009 Share Posted July 20, 2009 Can you post the code with FORM tags also, I think you may have two submit buttons maybe in one form? Link to comment Share on other sites More sharing options...
EmperorZenos Posted July 20, 2009 Author Share Posted July 20, 2009 Can you post the code with FORM tags also, I think you may have two submit buttons maybe in one form?Yes I do, and I'm thinking there is something wrong with that. >.> Link to comment Share on other sites More sharing options...
justsomeguy Posted July 20, 2009 Share Posted July 20, 2009 Not necessarily, as long as you plan for it. There's a description about how to handle more than one submit button in a form here:http://w3schools.invisionzone.com/index.php?showtopic=12509 Link to comment Share on other sites More sharing options...
EmperorZenos Posted July 20, 2009 Author Share Posted July 20, 2009 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 More sharing options...
EmperorZenos Posted July 20, 2009 Author Share Posted July 20, 2009 Ah, sorry for the double post, but it worked. That is, using two different pages for the entry.I'll try this for the first situation but thanks for helping everybody! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.