Jump to content
Sign in to follow this  
Panta

My Login Script

Recommended Posts

Please help me out

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Register!</title></head><body><form action='register.php' method='POST'>Username: <input type='text' name='username'><br>Password: <input type='password' name='password'><br><input name="register" type="submit" value="Submit"></form><?phpinclude('config.php');///variables...$submit=$_POST['register'];$username = mysql_real_escape_string(strip_tags(htmlspecialchars($_POST['username'])));$password = md5($_POST['password']);//if button is pressedif($submit){//if username is not blank..same for passif(($username) and ($password) and ($username!==NULL) and ($password!==NULL)){$check="SELECT id FROM school WHERE username='".$username."'";$result = mysql_query($check) or die(mysql_error());$num_rows = mysql_num_rows($result); if ($num_rows != 0) { echo "Sorry, there the username $username is already taken.<br>";echo "<a href=register.html>Try again</a>";exit;}else{ $sql="INSERT INTO `users` (`id`,`username`,`password`) VALUES ('NULL','".$username."','".$password."')";mysql_query($sql) or die(mysql_error());echo "Congratulations! You are registered!<br><a href='index.php'>Log in</a>";}}}?></body></html>

the erro i'm experiencing is "Table 'school.school' doesn't exist"and i have my table "school created.

Edited by Panta

Share this post


Link to post
Share on other sites
check your database , your page code and your config.php for any typo's you've made in any sql query's.
i have done that. but could not see any erro. this is my config.php
<?php    $dbhost   = 'localhost';    $dbname   = 'school';    $dbusername   = '*****';    $dbuserpass = '******';        mysql_connect ($dbhost, $dbusername, $dbuserpass);mysql_select_db($dbname) or die('Cannot select database');?>

Share this post


Link to post
Share on other sites

I do believe you call for your database incorrectly , when I apply this script with 2 blank tables to substitute i find that the script itself works perfectly well.Only explanation can be that your database connection isn't propper! :)

Share this post


Link to post
Share on other sites

THANKS , THE PROBLEM IS THAT I DIDN'T CHOICE THE CORRECT DATABASE NAME.IS NOW WORKING PERFECTELY.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...