samoi Posted November 6, 2008 Share Posted November 6, 2008 Hi guys, I'm just wondering if I just make a reiteration script in only one page! and no html page to redirects the form to be $_POST submitted to another page! For example: The form.html <form action="register.php" method="POST"> username : <input type="text" name="username"> <br /> password : <input type="password" name="password"> <br /> <input type="submit" value="Insert into the db"> </form> and the register.php <?php $conn = mysql_connect("localhost", "root", "pass"); $db = mysql_select_db("database_name"); $username = clean($_POST['username']); $password = clean($_POST['password']); if(!$username || !$password) { echo " No input inserted! "; } else { $insert = "INSERT INTO users (username, password) VALUES ('$username', '$password')"; $do_insert = mysql_query($insert); echo "the data has been inserted succeffully"; } function clean($str) { return mysql_escape_string($str); } ?> The question is, can I make all of them in only on page? instead of doing them in two pages, and what are the positives and negatives of using this method? Thank you in advance. Link to comment https://forums.phpfreaks.com/topic/131580-solved-can-i-make-a-registration-form-in-only-one-script-page-more-details-inside/ Share on other sites More sharing options...
trq Posted November 6, 2008 Share Posted November 6, 2008 Of course you can. A simple example. <?php if (isset($_POST['submit'])) { // process form } else { // display form ?> <form action="" method="post"> <input type="submit" name="submit"> </form> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/131580-solved-can-i-make-a-registration-form-in-only-one-script-page-more-details-inside/#findComment-683403 Share on other sites More sharing options...
samoi Posted November 6, 2008 Author Share Posted November 6, 2008 Of course you can. A simple example. <?php if (isset($_POST['submit'])) { // process form } else { // display form ?> <form action="" method="post"> <input type="submit" name="submit"> </form> <?php } ?> thank you very much man you helped me alot I appreciate it . Link to comment https://forums.phpfreaks.com/topic/131580-solved-can-i-make-a-registration-form-in-only-one-script-page-more-details-inside/#findComment-683406 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.