Jump to content

Form is submitting to page


phreak3r

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.