Jump to content

Reece112233

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Reece112233's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. sorry pichachu i didnt know howto put code in... and the script is still not working
  2. yeah that done it jchones no more error but i still got a blank screen you got any ideas for that?
  3. im now getting an error saying Parse error: syntax error, unexpected ':' in C:\wamp\www\login.php on line 7 i tried changing the : to a ; which just said Parse error: syntax error, unexpected ';' in C:\wamp\www\login.php on line 7 i tried removing it completely and the screen went blank.. so i just clicked undo and left it as it is with the @ although if anyone would to come up with a solution to that problem i would use the person whos name begins with j (soz cant see name from the post reply screen) idea.. thanks
  4. ok ive edited my html code to this <html> <body> <form action="login.php if($login == "yes"){" method"post"> Username: <input type="text" name="username" /> <br> Password <input type="password" name="password" /> <br> <input type="submit" value="Login" /> </form> </body> <html> and my php file to this <?php error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); session_start(); $username = (!emtpy($_POST['user'])) ? trim($_POST["user"]) : NULL; $password = (!empty($_POST['pass'])) ? trim($_POST["pass"] : NULL; $login = (isset($_GET['login'])) ? trim($_GET["login"]) : NULL; setcookie("username","$username",time()+86400); if($login == "yes"){ $con = mysql_connect("localhost","root","arceye") or die('Cannot connect to server...'); mysql_select_db("login",$con) or die ('Cannot select that database...'); $get = mysql_query("SELECT count(`id`) as total FROM `login` WHERE `user`='$username' and `pass`='$password'",$con) or die(mysql_error()); $res = mysql_fetch_assoc($get); @mysql_close($con); $result = $res['total']; if($result !=1 ){ echo "Invalid Username Or Password"; exit(); }else{ echo "Login Successful"; $_SESSION["username"] = $username; header("location: login.html"); } } ?> ok? MOD EDIT: code tags added.
  5. the first part where it says oh i see you know your clever i meant to put oh i see . you know, your really clever
  6. oh i see you know your very clever. i added a @ before the $username stuff on the 6 , 7 , 8 line of the code and that sorted out the database not found error. i also added another user and pass to my database . the user is john and the pass is 1234 the id is 2 im now getting a blank webpage after i login nothing happens .. the website url is http://localhost/login.php?username=Admin&password=oliver i thought there might be an error and its not showing up so i edited the code to do error reporting but thats not working i just get a blank screen.. i have decided to include my html code in this bit because the part thats not working is a visual part usually handled by html . the html code is <html> <body> <form action="login.php" method"post"> Username: <input type="text" name="username" /> <br> Password <input type="password" name="password" /> <br> <input type="submit" value="Login" /> </form> </body> <html> and the new php code is <?php error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); session_start(); @$username = trim($_POST["user"]); @$password = trim($_POST["pass"]); @$login = trim($_GET["login"]); setcookie("username","$username",time()+86400); if($login == "yes"){ $con = mysql_connect("localhost","root","arceye") or die('Cannot connect to server...'); mysql_select_db("login",$con) or die ('Cannot select that database...'); $get = mysql_query("SELECT count(`id`) as total FROM `login` WHERE `user`='$username' and `pass`='$password'",$con) or die(mysql_error()); $res = mysql_fetch_assoc($get); @mysql_close($con); $result = $res['total']; if($result !=1 ){ echo "Invalid Username Or Password"; exit(); }else{ echo "Login Successful"; $_SESSION["username"] = $username; } } ?> NOTE: these are two separate files login.html and login.php both being stored in the www directory of my wamp server and can be accesses by typing localhost/login.html or localhost/login.php thanks MOD EDIT: code tags added.
  7. ok thats done the script is fine its now saying undefined index on line 3 , 4 and 5 . dunno why though the databases are definately there [attachment deleted by admin]
  8. another problem. got one on line 5 but fixed by changing % to $ a typo.. (i know what a typo is now) and line 7 the line b4 it was wrong fixed that now im onto line 19 error is Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\wamp\www\login.php on line 19 this is my code (well my code improved by you) so far <?php session_start(); $username = trim($_POST["user"]); $password = trim($_POST["pass"]); $login = trim($_GET["login"]); setcookie("username","$username",time()+86400); if($login == "yes"){ $con = mysql_connect("localhost","root","arceye") or die('Cannot connect to server...'); mysql_select_db("login",$con) or die ('Cannot select that database...'); $get = mysql_query("SELECT count(`id`) as total FROM `login` WHERE `user`='$username' and `pass`='$password'",$con) or die(mysql_error()); $res = mysql_fetch_assoc($get); @mysql_close($con); $result = $res['total']; if($result !=1 ){ echo "Invalid Username Or Password"; exit(); }else{ echo "Login Successful" $_SESSION["username"] = $username; } } ?> thanks once again
  9. Nope it dosent work although i like this code better it now says Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\login.php on line 3 and what is a typo this is the code i wrote i dont see any differance in the 3rd line <?php session_start $username = trim($_POST["user"]); $password = trim($_POST["pass"]); %login = trim($_GET["login"]); setcookie("username","$username",time()+86400) if($login == "yes"){ $con = mysql_connect("localhost","root","arceye") or die('Cannot connect to server...'); mysql_select_db("login",$con) or die ('Cannot select that database...'); $get = mysql_query("SELECT count(`id`) as total FROM `login` WHERE `user`='$username' and `pass`='$password'",$con) or die(mysql_error()); $res = mysql_fetch_assoc($get); @mysql_close($con); $result = $res['total']; if($result !=1 ){ echo "Invalid Username Or Password"; exit(); }else{ echo "Login Successful" $_SESSION["username"] = $username; } } ?> thanks... MOD EDIT: code tags added.
  10. thanks im writing it into notepad++ now i cant copy and paste cause it all comes out in one line
  11. Sorry About this but i seriusly need to get my scouts site up im double posted just look for the post thats titled Ratnayes... Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\wamp\www\login.php on line 23 its near this one thx
×
×
  • 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.