ArizonaJohn Posted June 1, 2009 Share Posted June 1, 2009 Hello, The first section of code below returns a message that says "The topic 'x' has not been added." if a user enters a topic that is not in my database. I would like to give the user the option to add "x" to the database by clicking on an HTML submit button. So I guess my problem is that I don't know how to add an HTML submit button within PHP that would post $name=$find to tprocess.php and then trigger the code in tprocess.php. How do I do that? Thanks. $anymatches=mysql_num_rows($result); if ($anymatches == 0) { print "<p class=\"topic2\">The topic \"$find\" has not been added.</p>\n"; print "<p class=\"topic2\">Add the topic \"$find\".</p>\n"; <form action="tprocess.php" method="post">; $name=$find; <input type="submit" value="Submit">"; </form>; Below is what I have on tprocess.php. It is code that adds a topic to my database: if (isset($_POST['name']) && !empty($_POST['name'])) { mysql_connect("mysqlv10", "username", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); $table = mysql_real_escape_string($_POST['name']); $query = "CREATE TABLE `$table` (id INT(11) NOT NULL auto_increment, site VARCHAR(150) NOT NULL, votes_up BIGINT(9) NOT NULL, votes_down BIGINT(9) NOT NULL, PRIMARY KEY(id), UNIQUE (site))"; $result = mysql_query($query) or die(mysql_error()); } Link to comment https://forums.phpfreaks.com/topic/160557-html-submit-button-within-php/ Share on other sites More sharing options...
ldougherty Posted June 1, 2009 Share Posted June 1, 2009 Just echo it out. echo "<form action='tprocess.php' method='post'>"; $name=$find; echo "<input type='submit' value='Submit'>"; echo "</form>;"; Link to comment https://forums.phpfreaks.com/topic/160557-html-submit-button-within-php/#findComment-847384 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.