Jump to content

Recommended Posts

Ok, I am a complete noob when it comes to php. I am slowly learning it but I turned to youtube for a tutorial on a registration/login page. I found a good tutorial

but for some reason my php is NOT working. I have it exactly the way he does but it wont echo anything or work at all. The login page worked great in his tutorial. What do I have wrong? I cant figure it out. Please help!

 

 

echo "<h1>Register</h1>";

$submit = $_POST['submit'];
$fullname = strip_tags($_POST['name']);
$username = strip_tags($_POST['user']);
$password = strip_tags($_POST['password']);
$verifypassword = strip_tags($_POST['verifypassword']);
$date = date("Y-m-d");

if ($submit)
{
     if($fullname&&$username&&$password&&$verifypassword)
     {
          password = md5($password);
          verifypassword= = md5($verifypassword);
     }
     else
         echo "Please fill in all fields!";

}

<html>
<form action='register.php' method='POST'>
      <table>
              <tr>
                   <td>Full Name:</td>
                   <td><input type='text' name='name'></td>
              </tr>
              
              <tr>
                   <td>Username:</td>
                   <td><input type='text' name='user'></td>
              </tr>
               
               <tr>
                   <td>Password:</td>
                   <td><input type='password' name='password'></td>
              </tr>

              <tr>
                   <td>Verify Password:</td>
                   <td><input type='password' name='verifypassword'></td>
              </tr>
      </table>
      <p><input type='submit' name='submit' value='Submit'></p>
</form>

</html>

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/
Share on other sites

write this script:

 

phpinf.php

 

<?php
phpinfo();
?>

 

what does it say?

 

Shows nothing at all

 

If you input the proper fields then nothing is supposed to output.  What happens when you don't fill in one of the 4 fields in the IF statement?  Does "Please fill in all fields!" output?

 

I know, I should of been more clear. When you input nothing it should echo "Please fill in all fields" and its not doing that...You can try to echo anything and it wont work. Header isn't working either.....Thats what I cant figure out.

Can you post the entire PHP script?

 

Well this is what I have so far. I haven't finished the tutorial yet because when it wasn't working I didn't go any further.

 

Here is the index page

        <html>

<form action="login.php" method='POST'>
	Username: <input type='text' name='username'><br />   <br />
	Password: <input type='password' name='password'><br />
	<input type='submit' value='Log in'>
</form>

 <p>Not already a member? Click <a href='register.php'>here</a> to register!</p>
        </html>

 

There here is the login.ohp ( this one works great)

<?php

$username = $_POST['username'];
$password = $_POST['password'];

if ($username&&$password)
{
$connect = mysql_connect("localhost", "root", "q9pl8mq") or die("Couldn't connect to server.");
mysql_select_db("phplogin") or die("Database Not Found");

$query = mysql_query("SELECT * FROM users WHERE username='$username'");

$numrows = mysql_num_rows($query);

if ($numrows!=0)
{
  while ($row = mysql_fetch_assoc($query))
  {
      $dbusername = $row['username'];
      $dbpassword = $row['password'];

  }
  //check to see if it matches
  
  if($username==$dbusername&&$password==$dbpassword)
  {
    echo"Login Successfull!";
  }
  else
    echo"Password Incorrect";

}

else
   die("Username doesn't exist!");

}

else
    die("Please enter your username and password!");

?>

 

 

Then the register.php thats NOT working but can't figure out why...

<?php


$submit = $_POST['submit'];
$fullname = strip_tags($_POST['name']);
$username = strip_tags($_POST['user']);
$password = strip_tags($_POST['password']);
$verifypassword = strip_tags($_POST['verifypassword']);
$date = date("Y-m-d");

if ($submit)
{
     if($fullname&&$username&&$password&&$verifypassword)
     {
          password = md5($password);
          verifypassword= = md5($verifypassword);
     }
     else
         echo "Please fill in all fields!";

}
?>


<html>
<form action='register.php' method='POST'>
      <table>
              <tr>
                   <td>Full Name:</td>
                   <td><input type='text' name='name'></td>
              </tr>
              
              <tr>
                   <td>Username:</td>
                   <td><input type='text' name='user'></td>
              </tr>
               
               <tr>
                   <td>Password:</td>
                   <td><input type='password' name='password'></td>
              </tr>

              <tr>
                   <td>Verify Password:</td>
                   <td><input type='password' name='verifypassword'></td>
              </tr>
      </table>
      <p><input type='submit' name='submit' value='Submit'></p>
</form>

</html>

 

[attachment deleted by admin]

There's your problem (most likely). You need to access the file so that the web server parses it. http://localhost/lesson1/register.php may work, or you might need to specify a port number if it isn't the standard port. If the port number that's configured is other than port 80 in your settings, it would be

http://localhost:your port number here/lesson1/register.php

There's your problem (most likely). You need to access the file so that the web server parses it. http://localhost/lesson1/register.php may work, or you might need to specify a port number if it isn't the standard port. If the port number that's configured is other than port 80 in your settings, it would be

http://localhost:your port number here/lesson1/register.php

 

 

Thank You!!! I should have known better! Not sure how I got off track though because I was under local host with the login.php because it was working. Oh well my problem is fixed.. Thanks again!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.