Jump to content

Hooo

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Hooo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <html> <body> <?php include 'config.php'; include 'opendb.php'; session_start(); $userfinal=$_SESSION['usname']; $messageid = $_GET['message']; $message = mysql_query("SELECT * FROM `messages` WHERE `message_id` = '{$messageid}' AND `to_user` = '{$userfinal}'") or die(mysql_error()); $MessageRecieved=mysql_fetch_assoc($message); echo "<h1>Title: ".$MessageRecieved['message_title']."</h1><br><br>"; echo "<h3>From: ".$MessageRecieved['from_user']."<br><br></h3>"; echo "<h3>Message: <br>".$MessageRecieved['message_contents']."<br></h3>"; echo '<form name="backfrm" method="post" action="inbox.php">'; echo '<input type="submit" value="Back to Inbox">'; echo '</form>'; ?> </body> </html> No luck, did I miss something? :/
  2. Basically, the code I will paste is the read message link. What happens is the message sends perfectly, however when clicking on the actual title the page (Below) doesn't actually show what it is supposed to, this being the message title, message contents etc. <html> <body> <?php include 'config.php'; include 'opendb.php'; session_start(); $userfinal=$_SESSION['usname']; $messageid = $_GET['message']; $message = mysql_query("SELECT * FROM `messages` WHERE `message_id` = '{$messageid}' AND `to_user` = '{$userfinal}'") or die(mysql_error()); $message=mysql_fetch_assoc($message); echo "<h1>Title: ".$message['message_title']."</h1><br><br>"; echo "<h3>From: ".$message['from_user']."<br><br></h3>"; echo "<h3>Message: <br>".$message['message_contents']."<br></h3>"; echo '<form name="backfrm" method="post" action="inbox.php">'; echo '<input type="submit" value="Back to Inbox">'; echo '</form>'; ?> </body> </html>
  3. Basically, code works fine (somehow, I know it looks a mess ). Anyway, a few minor problems .. #1. When the form has been completed and the registration is successful, it echos this top left of the page which is fine for now, however the register form also reappears, I want to make it so that doesn't reappear, is there a way? #2. It is possible for people to click refresh and duplicate an entry, also if I visit the link directly it again creates a duplicate entry in the Users table. Not so minor this one, but i'm sure theres something simple to fix it. If there is anything else you spot which needs to be adjusted, please do tell <html> <body> <?php include 'config.php'; include 'opendb.php'; if ($_POST['Submit']) { $uname = $_POST["uname"]; $pword = $_POST["pword"]; $pword1 = $_POST["pword1"]; $jmail = $_POST["email"]; $age = $_POST["age"]; $chkname = mysql_query("SELECT * FROM Users WHERE usname='$uname'"); $salt = 's+(_a*'; $salt_pass = md5($pword.$salt); $ip = $_SERVER['REMOTE_ADDR']; $datum = date("d-m-y / H:i:s"); if(mysql_num_rows($chkname) > 0 ) { echo "Username already in use"; } else { if ($pword != $pword1) { echo "The two passwords do not match"; } else { if (strlen($pword) > 25 || strlen($pword) < 6 ) { echo "Your password must be between 6 and 25 characters!"; } else { if (strlen($uname) > 16 || strlen($uname) < 4 ) { echo "Your username must be between 4 and 16 characters!"; } else { $sql="INSERT INTO Users (usname, userpass, useremail, userage, JoinDate, IPAddress) VALUES ('$uname','$salt_pass','$jmail','$age','$datum','$ip')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } ?> Registation Successful!<br /><br /> You may now <a href="index.php">login!</a> <?php } } } } } ?> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" Method="POST" ACTION="index2.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Register </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="uname" type="text" id="uname" maxlength="16" /></td> <tr> <td>Password</td> <td>:</td> <td><input name="pword" type="password" id="pword" maxlength="25" /></td> <tr> <td>Re-enter</td> <td>:</td> <td><input name="pword1" type="password" id="pword1" maxlength="25" /></td> <tr> <td>Email</td> <td>:</td> <td><input name="email" type="text" id="email" maxlength="50" /></td> <tr> <td>Age</td> <td>:</td> <td><input name="age" type="text" id="age" maxlength="2" /></td> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Register"></td> </tr> </table> </td> </form> </tr> </table> <?php include 'closedb.php'; ?> </body> </html>
  4. Been searching and can't find out how to do these.. Just simply want them to be logged on signup and maybe login and store last 3/5 login IPs if thats possible.. Data also, so date registered and date last logged in. Is there any suggestions on how to go about doing this? Thanks.
  5. If nobody can make sense of my code, is there an easier way I can do this? Sorry for double post
  6. Took out the extra <html> and opening PHP at the top which crashed the page, but when I try to change I still get "the two passwords didn't match"
  7. Here is what I have, the basic aim of the script is to change password, does a couple of checks like Old password matches password they input on the previous form, and new password matches the new password confirm box in the form also. I know it is bad as it is, I have been trying to fix it, however things are just not going well At the moment with the code I have it says "The two passwords didn't match.. Thanks for any help given. <html> <body> <?php include 'config.php'; include 'opendb.php'; session_start(); if(isset($_SESSION['usname'])) { ?> <table width="320" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="changepw" method="post" action="changepw1.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong> Change Your Password </strong></td> </tr> <tr> <td width="200">Old Password</td> <td width="6">:</td> <td width="294"><input name="opass" type="password" id="opass"></td> </tr> <tr> <td>New Password</td> <td>:</td> <td><input name="npass" type="password" id="npass"></td> </tr> <tr> <td>Re-enter</td> <td>:</td> <td><input name="npass1" type="password" id="npass1"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Change Password"></td> </tr> </table> </td> </form> </tr> </table> <?php } else { echo '<meta http-equiv="refresh" content="2;url=index.php">'; } ?> </body> </html> and <?php include 'config.php'; include 'opendb.php'; session_start(); $opass = $_POST["opass"]; $npass = $_POST["npass"]; $npass1 = $_POST["npass1"]; $salt = 's+(_a*'; $salt_passo = md5($opass.=$salt); $salt_passn = md5($npass.=$salt); $result = mysql_query("SELECT userpass FROM Users WHERE usname = '{$_SESSION['usname']}'") or die(mysql_error()); $row=mysql_fetch_assoc($result); if(isset($_SESSION['usname'])) { if ($salt_passo != $row['userpass']) { echo "Your old password was entered incorrectly"; } elseif ($npass != $npass1) { echo "The two new password didn't match"; } else { mysql_query("UPDATE `Users` SET `userpass`='{$salt_passn}' WHERE `usname` = '{$_SESSION['usname']}'") or die("Error: ".mysql_error()); } } else { echo '<meta http-equiv="refresh" content="2;url=index.php">'; } ?>
  8. Isn't =.= I must be annoying you <3
  9. Edited my post, sorry, noticed that mistake There is no need to check when both are encrypted as it will encrypt with the SQL anyway, so I checked npass != npass1. Both of which are taken directly from the previous form, and should both be filled with the same password.
  10. No, the code I have (Changed from first time I posted) elseif ($npass != $npass1) { echo "The two new password didn't match"; } and the Variables: $opass = $_POST["opass"]; $npass = $_POST["npass"]; $npass1 = $_POST["npass1"]; $salt = 's+(_a*'; $salt_passo = md5($opass.=$salt); $salt_passn = md5($npass.=$salt);
  11. Haha, think we are getting there *sigh* Now I get: The two new password didn't match I don't see anything similar wrong with that however :/
  12. $salt = 's+(_a*'; $salt_pass = md5($pword.$salt); Then: $sql="INSERT INTO Users (usname, userpass, useremail, userage) VALUES ('$uname','$salt_pass','$jmail','$age')"; Appears to be the same to me
  13. Done what you have suggested, however now when I enter the old pass, plus a new passX2, I get: Your old password was entered incorrectly. Could this be something to do with the encrypting? I believe I have used the same algorithm of md5 + $salt Thanks
  14. Basically, the script is to change a password once a member is logged in. So first I include the files, start the session and ask if a session is set. If it is ( { ) then the elses happen, like if old password inputted into form beforehand matches pass in database, carry on, if not, echo error basically. Then it checks that both New Password and Confirm New Password fields are matching, and carries on and does the SQL update. At the end, the if session set ends with a redirect to index, which is the login page. Hope you understand? Thanks, I know it isn't pretty either
×
×
  • 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.