Jump to content

Recommended Posts

DO_Login.php

<?php

 

$connection = mysql_connect(localhost , root, "");

$db = mysql_select_db(user, $connection);

 

$sql = "SELECT id FROM users

    WHERE username='$_POST[username]'

    AND password='$_POST[password]'";

 

$result = mysql_query($sql) or die(mysql_error());

$num = mysql_num_rows($result);

 

if ($num > 0) {

        //USER AND PASS ARE CORRECT

$id = mysql_fetch_assoc($result);

 

setcookie("auth", "yes", time()+3600);

setcookie("id", $id['id']);

setcookie("username", $id['username']);

 

header ("Location: main.php");

 

}else {

header ("Location: incorrect.php");

};

 

?>

 

 

 

Login.PHP

<body background="blue.jpg">

<font face="arial">

<form name=login action=do_login.php method=post>

<table border=0 cellspacing=0 cellpadding=2>

<tr><td>

<font face="sans-serif"><font color="black">Username:</font></b></font></font><td><input type=text name=username>

<tr><td>

<font face="sans-serif"><font color="black">Password:</font></b></font></font><td><input type=password name=password>

<tr><td colspan=2 align=left><img src="blue.jpg"height="2" width="70"><input type="checkbox" name="remember">

<font size="2"><font face="sans-serif"><font color="black">Remember Me</font></b></font></font><img src="blue.jpg"height="2" width="93"><input type=submit value='Login!'><form method="GET" action="refreshbutton.htm" align=right><input type="button" onclick="refresh()" value="Reset"

  name="button1">

</table>

</form>

 

</body>

 

</html>

 

 

 

<html>

 

<head>

<script language="JavaScript">

 

-->

 

<!--

 

/.

 

var sURL = unescape(window.location.pathname);

 

function refresh()

{

    window.location.href = sURL;

}

//-->

</script>

 

<script language="JavaScript1.1">

<!--

function refresh()

{

    window.location.replace( sURL );

}

//-->

</script>

 

<script language="JavaScript1.2">

<!--

function refresh()

{

    window.location.reload( false );

}

//-->

</script>

</head>

 

<body>

 

 

 

<!--

</form>

 

</body>

 

</html>

 

 

 

 

 

 

 

 

 

 

Incorrecy.php

<body background="blue.jpg">

 

blank because i dont have a source as to MAIN.php

If the login is incorrect I'd send them back to the login and show an error message something like

 

"Incorrect username or password"

 

}else {
header ("Location: login.php?error=y");
}

 

And in login.php

<?php

if (isset($_GET['error']) && $_GET['error']=='y') echo "Incorrect username or password";

// login form here

 

<font face="arial">

<body background="blue.jpg">

<?php

 

if (isset($_GET['error']) && $_GET['error']=='y') echo "Incorrect username or password";

 

// <form name=login action=do_login.php method=post>

<table border=0 cellspacing=0 cellpadding=2>

<tr><td>

<font face="sans-serif"><font color="black">Username:</font></b></font></font><td><input type=text name=username>

<tr><td>

<font face="sans-serif"><font color="black">Password:</font></b></font></font><td><input type=password name=password>

<tr><td colspan=2 align=left><img src="blue.jpg"height="2" width="70"><input type="checkbox" name="remember">

<font size="2"><font face="sans-serif"><font color="black">Remember Me</font></b></font></font><img src="blue.jpg"height="2" width="93"><input type=submit value='Login!'><form method="GET" action="refreshbutton.htm" align=right><input type="button" onclick="refresh()" value="Reset"

  name="button1">

</table>

</form>

 

</body>

 

</html>

 

 

 

<html>

 

<head>

<script language="JavaScript">

 

-->

 

<!--

 

/.

 

var sURL = unescape(window.location.pathname);

 

function refresh()

{

    window.location.href = sURL;

}

-->

</script>

 

<script language="JavaScript1.1">

<!--

function refresh()

{

    window.location.replace( sURL );

}

-->

</script>

 

<script language="JavaScript1.2">

<!--

function refresh()

{

    window.location.reload( false );

}

//-->

</script>

</head>

 

<body>

 

 

 

<!--

</form>

 

</body>

 

</html>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Erorr:Parse error: syntax error, unexpected '<' in C:\wamp2\www\Saintsprojects\login.php on line 8

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.