phreak3r Posted January 14, 2018 Share Posted January 14, 2018 (edited) Hi there PHPFreaks, phreak3r here again. The thread I posted yesterday has been solved. If any staff come across this, please lock it to prevent further discussion; I would appreciate that, please and thank you! I am back with another problem! This forum is all contained in one page. I am doing a very basic login system for now (I will add in everything else in later) and it does not work. I go to submit the forum and the values are displayed in the url after the page refreshes. Here's the code for the login.php script involved: <?php 2 include('header.php'); 3 require('dbcon/dbcon.php'); 4 ?> 5 6 <?php 7 if (isset($_POST['submit'])) { 8 $username = mysqli_real_escape_string($conn, $_POST['username']); 9 $password = mysqli_real_escape_string($conn, $_POST['password']); 10 $sql = "SELECT * FROM profile0 WHERE username = '$username' "; 11 $query = mysqli_query($conn, $sql); 12 13 if (mysqli_num_rows($query) == 1) { 14 // init session 15 // redirect to new page 16 header('main.php'); 17 } 18 } 19 ?> 20 21 <!DOCTYPE html> 22 <html> 23 <head> 24 <title>soapbox - log in</title> 25 </head> 26 <body> 27 <form action="login.php" method"POST"> 28 <br><input type="text" name="username" placeholder="Username"><br> 29 <br><input type="password" name="password" placeholder="Password"><br> 30 <input type="submit" name="submit" value="Submit"> 31 </form> 32 </body> 33 </html> EDIT: No errors in the error log. Edited January 14, 2018 by phreak3r Quote Link to comment https://forums.phpfreaks.com/topic/306183-form-is-submitting-to-page/ Share on other sites More sharing options...
Solution Barand Posted January 14, 2018 Solution Share Posted January 14, 2018 In your form tag you have method"POST" which is missing the "=" sign. As the default method is GET, the values are passed in the url instead of being POSTed. Quote Link to comment https://forums.phpfreaks.com/topic/306183-form-is-submitting-to-page/#findComment-1555321 Share on other sites More sharing options...
phreak3r Posted January 14, 2018 Author Share Posted January 14, 2018 In your form tag you have method"POST" which is missing the "=" sign. As the default method is GET, the values are passed in the url instead of being POSTed. Thank You! I have fixed that silly mistake, but I am not taken to the main.php page upon logging on. Quote Link to comment https://forums.phpfreaks.com/topic/306183-form-is-submitting-to-page/#findComment-1555322 Share on other sites More sharing options...
Barand Posted January 14, 2018 Share Posted January 14, 2018 Your header syntax is screwed up too. Try header("Location: main.php"); exit; Quote Link to comment https://forums.phpfreaks.com/topic/306183-form-is-submitting-to-page/#findComment-1555323 Share on other sites More sharing options...
phreak3r Posted January 14, 2018 Author Share Posted January 14, 2018 Your header syntax is screwed up too. Try header("Location: main.php"); exit; Thank you very much for your assistance Barand! This issue has been solved, you may close the thread to further discussion, please and thank you! Have a great day! Quote Link to comment https://forums.phpfreaks.com/topic/306183-form-is-submitting-to-page/#findComment-1555324 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.