 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Jul 11, 2008 8:37 am Post subject: [PHP]logging in |
|
|
I'm trying to understand logging in. Because I was thinking how do I validate a correct log-in and I remember sessions. Just I don't totally get sessions. And even still, I'm not quite sure why that's important anyway, or how to use it really. I got this, but I think it's wrong....
| Code: |
<?php
include('connect.php');
$username = $_POST[username];
$password = $_POST[password];
$sql = "SELECT * FROM accounts WHERE username = '$username' AND password = '$password'";
if(!mysql_query($sql, $con)) {
echo "Invalid username or password!";
exi();
}
else {
start_session();
//then what o.O
}
mysql_close($con);
?>
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Mussy69 Grandmaster Cheater
Reputation: 0
Joined: 09 Mar 2007 Posts: 842 Location: Sydney
|
Posted: Fri Jul 11, 2008 9:23 am Post subject: |
|
|
I'm not the best person with PHP but this should work
| Code: | <?
include("connect.php");
if($_SESSION['uname'] <= ""){
echo ' | <a href="otherfeatures.php">other features</a> | <a href="other features.php">Other features</a>';
} else {
echo ' | <a href="otherfeatures.php">other features</a> | <a href="other features.php">other features</a>';
}
?>
<br>
<strong>
<center>
<?
$submit = $_POST['submit'];
$uname = $_POST['uname'];
$pword1 = $_POST['pword'];
$pwordq = stripslashes("$pword1");
$what = array('"');
$then = array('');
$output = str_replace($what, $then, $pwordq);
$pword = $output;
if($_POST['submit'] == "1"){
$checkpass = "SELECT password FROM accounts WHERE name = '$uname'";
$checkpassq = @mysql_query("$checkpass");
$checkpassr = @mysql_result($checkpassq,0);
$checkpass = "SELECT name FROM accounts WHERE name = '$uname'";
$checkpassq = @mysql_query("$checkpass");
$num_rows = @mysql_num_rows($checkpassq);
if($num_rows > "0"){
if($pword == $checkpassr){
$_SESSION['uname'] = $uname;
$_SESSION['log'] = "yes";
echo "Whatever you want your message to display after login ( will redirect after 3 seconds ).";
echo "<meta http-equiv=refresh content=3;url=/>";
} else {
echo "The information you have entered is incorrect.";
}
} else {
echo "That account has not been registered";
}
}
?>
<b><form method="post">
<input type=hidden name="submit" value="1">
Username:
<input type=text name="uname"><? if($uname == "") { echo '<font color=red>*</font>'; } ?><br>
Password:
<input type=password name="pword"><? if($pword == "") { echo '<font color=red>*</font>'; } ?><br>
<input type=submit value="Login">
</form>
</b></font>
</center>
</STRONG>
|
Edit that code to your variables or whatever lawl _________________
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|