Jump to content

Panta

Members
  • Content Count

    115
  • Joined

  • Last visited

Everything posted by Panta

  1. Panta

    Login Count

    friends please i need you to look into my script .what i need is a script that will count a user as the user logs in.And when the user logs in 3 times to the site he will not be able to log in again. The script <?session_start();session_destroy();?><table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"><tr><form name="form1" method="post" action="checklogin.php"><td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"><tr><td colspan="3"><strong>Member Login </strong></td></tr><tr><td width="78">Username</td><td width="6">:</td><td width="294"><input name="username" type="text" id="username"></td></tr><tr><td>Password</td><td>:</td><td><input name="password" type="text" id="password"></td></tr><tr><td> </td><td> </td><td><input type="submit" name="Submit" value="Login"></td></tr></table></td></form></tr></table>checklogin.php<?php$host="localhost"; // Host name$username="root"; // Mysql username$password=""; // Mysql password$db_name="logins"; // Database name$tbl_name="logins"; // Table name// Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect");mysql_select_db("$db_name")or die("cannot select DB");// username and password sent from form$username=$_POST['username'];$password=$_POST['password'];// To protect MySQL injection (more detail about MySQL injection)$username = stripslashes($username);$password = stripslashes($password);$username = mysql_real_escape_string($username);$password = mysql_real_escape_string($password);//$sql1="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";//$result1=mysql_query($sql1);// Mysql_num_row is counting table row//$count=mysql_num_rows($result1);// If result matched $myusername and $mypassword, table row must be 1 row$sql="SELECT username,password,logins FROM $tbl_name WHERE username='$username'and logins='$logins'";$query=mysql_query($sql);$result = MYSQL_QUERY($query);/* check the total number of logins */if($result['$logins']==3) {$TooManyLogins="Yes";}else {$sql2="UPDATE table SET $logins=$logins+1";mysql_query($sql2);}if($username===$result['username'] && $password===$result['password']) {if($TooManyLogins==="Yes") {echo "Your Logins have expired";exit();}else {if($logins==1){// Register $myusername, $mypassword and redirect to file "login_success.php"session_register("username");session_register("password");header("location:login_success.php");}else {echo "Wrong Username or Password";}}}?> i think this is not working
  2. Panta

    My Login Script

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

    My Login Script

    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');?>
  4. Panta

    My Login Script

    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.
  5. Panta

    Login Script

    please my friends this has been my problem. this time what the erro message is "Parse error: syntax error, unexpected $end in C:\wamp\www\newform\register2.php on line 47"This is the code...please i need ur help. Thanks <?php// Connects to your Databasemysql_connect("localhost", "user", "lpw") or die(mysql_error());mysql_select_db("Database_Name") or die(mysql_error());//This code runs if the form has been submittedif (isset($_POST['submit'])) {//This makes sure they did not leave any fields blankif (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {die('You did not complete all of the required fields');}// checks if the username is in useif (!get_magic_quotes_gpc()) {$_POST['username'] = addslashes($_POST['username']);}$usercheck = $_POST['username'];$check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'")or die(mysql_error());$check2 = mysql_num_rows($check);//if the name exists it gives an errorif ($check2 != 0) {die('Sorry, the username '.$_POST['username'].' is already in use.');}// this makes sure both passwords entered matchif ($_POST['pass'] != $_POST['pass2']) {die('Your passwords did not match. ');}// here we encrypt the password and add slashes if needed$_POST['pass'] = md5($_POST['pass']);if (!get_magic_quotes_gpc()) {$_POST['pass'] = addslashes($_POST['pass']);$_POST['username'] = addslashes($_POST['username']);}// now we insert it into the database$insert = "INSERT INTO users (username, password)VALUES ('".$_POST['username']."', '".$_POST['pass']."')";$add_member = mysql_query($insert);?> Solved. Thanks
  6. Panta

    Login Script

    please i dont know the problem with this login script. the error message is Fatal error: Call to undefined function msql_query() in C:\wamp\www\newform\login.php on line 33 //connect to the mysql database server.mysql_connect ($dbhost, $dbusername, $dbuserpass);mysql_select_db($dbname) or die('Cannot select database');$page_mode = isset($_POST['page_mode']) ? $_POST['page_mode'] : '';$error_string = '';if ($page_mode == 'login'){ $email = $_POST['email']; $password = $_POST['password']; if (trim($email) == '' || trim($password) == '') { $error_string .= 'Please enter your email address and password.<br>'; } } else { $query = msql_query("SELECT * FROM users WHERE email='" . mysql_real_escape_string($email) . "'"); $data = mysql_fetch_array($query); if($data['password'] != $password) {echo "The supplied login is incorrect";}else{$query = mysql_query("SELECT* FROM users WHERE email='" . mysql_real_escape_string($email) . "'") ;$row = mysql_fetch_array($query); $_SESSION['user_id'] = $row['id']; $_SESSION['user_name'] = $row['name']; $_SESSION['user_email'] = $row['email']; header('Location: index.php'); exit(); } }?>
  7. Panta

    Can Somebody Help Me Now

    I have corrected the problem.Thanks
  8. // connect to the mysql database server.mysql_connect ($dbhost, $dbusername, $dbuserpass);mysql_select_db($dbname) or die("Cannot select database");//Are they just getting here or submitting their info?if (isset($_POST["username"])) {$username = $_POST["username"];$password = $_POST["password"];$cpassword = $_POST["cpassword"];$email = $_POST["email"];//Was a field left blank?if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL) {echo "A field was left blank.";}else{//Do the passwords match?if($password!=$cpassword) {echo "Passwords do not match";}else{//Has the username or email been used?$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");$username_exist = mysql_num_rows($checkuser);$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");$email_exist = mysql_num_rows($checkemail);if ($email_existɬ|$username_existɬ) {echo "The username or email is already in use";}else{$pin = rand(1000000000,9999999999);//Everything seems good, lets insert.$query = "INSERT INTO users (username, password, email,regno) VALUES('$username','$password','$email','$pin')";mysql_query($query) or die(mysql_error());echo "The user $username has been successfully registered.";echo "Your reg no is" $pin;}}}}?><h1>Register</h1><form action="register.php" method="POST"><table style="border:1px solid #000000;"><tr><td align="right">Username: <input type="text" size="15" maxlength="25" name="username"></td></tr><tr><td align="right">Password: <input type="password" size="15" maxlength="25" name="password"></td></tr><tr><td align="right">Confirm Password: <input type="password" size="15" maxlength="25" name="cpassword"></td></tr><tr><td align="right">Email: <input type="text" size="15" maxlength="25" name="email"></td></tr><tr><td align="center"><input type="submit" value="Register"></td></tr><tr><td align="center"><a href="login.php">Login Here</a></td></tr></table></form></center> This is my script but i don't know where the problem is coming from.i guess the script is having a little erro.Plz help me
  9. thanks i will cheack 4 it
  10. yes i have both in my data base, so i need help on how to display the image so that thet user will see it on the browser
  11. please i need to know how to write a script that will change the content of Department on selection of Faculty.What i mean is maybe on selection of Sciences from Faculty, the content of Department will change to Science Departments. <form>Department:<select><option>Mechanical</option><option>Chemical</option><option>Civil</option></select><br>Faculty:<select><option>Engineering</option><option>Sciences</option><option>Law</option></select></form>
  12. please i need to know how to write a script that will change the content of Department on selection of Faculty.What i mean is maybe on selection of Sciences from Faculty, the content of Department will change to Science Departments. <form>Department:<select><option>Mechanical</option><option>Chemical</option><option>Civil</option></select><br>Faculty:<select><option>Engineering</option><option>Sciences</option><option>Law</option></select></form>
  13. Please friends please help me on how to display a picture that is in the data base on a browser, so that the user can see his uploded picture, and if possible print. thanks
  14. THE PROBLEM IS THAT THE SCRIPT IS NOT CORRECT. I DONT KNOW WHERE THE PROBLEM IS FROM, THE MORE I TRIED TO CORRCT IT THE MORE ERROR I SEE
  15. Please nice friends i have been trying to write a script that will upload pix to database and also pull it out to the browser, But i have been having problem with my code, Plz help me out. This is the code. Thanks <?php$db = mysql_connect("localhost","Austin","password");mysql_select_db("school");$pname = $_REQUEST['pname'];$pdesc = $_REQUEST['pdesc'];$ftype = $_FILES['pfile']['type'];$fname = $_FILES['pfile']['name'];if ($_FILES['pfile']['size'] <= $_REQUEST['MAX_FILE_SIZE']){$fdata = fread(fopen($_FILES['pfile']['tmp_name'], "rb"),$_FILES['pfile']['size']);$fdata = base64_encode($fdata);$sql = "INSERT INTO pictures “;$sql .= “(poster_name,pdesc,ftype,fname,fdata) VALUES “;$sql .= “(\"${pname}\",\"${pdesc}\",”;$sql .= “\"${ftype}\",\"${fname}\",\"${fdata}\")";$query = mysql_query($sql) or die(mysql_error());echo "File Uploaded!";} elseecho "File Too Large";?>
×
×
  • Create New...