GRD_98 Posted January 17, 2011 Share Posted January 17, 2011 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] Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/ Share on other sites More sharing options...
guyfromfl Posted January 17, 2011 Share Posted January 17, 2011 write this script: phpinf.php <?php phpinfo(); ?> what does it say? Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160941 Share on other sites More sharing options...
Maq Posted January 17, 2011 Share Posted January 17, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160944 Share on other sites More sharing options...
GRD_98 Posted January 17, 2011 Author Share Posted January 17, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160947 Share on other sites More sharing options...
Maq Posted January 17, 2011 Share Posted January 17, 2011 Can you post the entire PHP script? Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160950 Share on other sites More sharing options...
guyfromfl Posted January 17, 2011 Share Posted January 17, 2011 I don't think you have something configured correctly then. the phpinfo() function should spit out a couple tables with the server info in it. Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160951 Share on other sites More sharing options...
Pikachu2000 Posted January 17, 2011 Share Posted January 17, 2011 How are you calling the scripts into your browser? Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160955 Share on other sites More sharing options...
GRD_98 Posted January 17, 2011 Author Share Posted January 17, 2011 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] Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160956 Share on other sites More sharing options...
GRD_98 Posted January 17, 2011 Author Share Posted January 17, 2011 How are you calling the scripts into your browser? I am using xampp Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160959 Share on other sites More sharing options...
Maq Posted January 17, 2011 Share Posted January 17, 2011 You have a fatal error here: password = md5($password); verifypassword= = md5($verifypassword); You need to prefix variable names with '$'. Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160960 Share on other sites More sharing options...
Pikachu2000 Posted January 17, 2011 Share Posted January 17, 2011 That isn't really what I meant . . . What is the address in the address bar of your browser when you load the script and it doesn't work? Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160961 Share on other sites More sharing options...
GRD_98 Posted January 17, 2011 Author Share Posted January 17, 2011 That isn't really what I meant . . . What is the address in the address bar of your browser when you load the script and it doesn't work? file:///C:/xampp/htdocs/lesson1/login_register/register.php Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160965 Share on other sites More sharing options...
Pikachu2000 Posted January 17, 2011 Share Posted January 17, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160967 Share on other sites More sharing options...
GRD_98 Posted January 17, 2011 Author Share Posted January 17, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160981 Share on other sites More sharing options...
Maq Posted January 17, 2011 Share Posted January 17, 2011 Glad you got it working but I'm still confused how your script was even running with those errors. Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1160982 Share on other sites More sharing options...
GRD_98 Posted January 17, 2011 Author Share Posted January 17, 2011 Glad you got it working but I'm still confused how your script was even running with those errors. It wasn't at first I had to fix the errors like you said! But now its working! Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1161006 Share on other sites More sharing options...
Maq Posted January 17, 2011 Share Posted January 17, 2011 Glad you got it working but I'm still confused how your script was even running with those errors. It wasn't at first I had to fix the errors like you said! But now its working! Good Quote Link to comment https://forums.phpfreaks.com/topic/224757-need-help-php-wont-work-at-all/#findComment-1161010 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.