checking db for data then doing one of two things.
Posted: Fri Oct 10, 2003 11:28 am
I am having trouble getting this to work and it's driving me nuts!
Basically it's supposed to allow users to set their username and password if they have entered their name and member no. ( which are already defined )
If the name and/or member have not been entered correctly then it redirects to nomatch.php
If the name and member have been entered correctly the username and password get entered in the db and redirect to index.php
Well that's the idea but it's not working and I can't figure out why.
?>
Code: Select all
<?php
$conn = mysql_connect("localhost","******","*******");
$db = mysql_select_db("*******");
$result = MYSQL_QUERY("SELECT realname, member from users WHERE realname='$realname' and member='$member'") or die ("Name and membership number not found or not matched");
$worked = mysql_fetch_array($result);
$realname = $worked[realname];
$member = $worked[member];
?>Code: Select all
<form action="<? echo $_SERVERї'PHP_SELF']; ?>" method="post" id="register">
<input type="text" name="realname" size="20" maxlength="30" value="name" class="clear" /><br />
<input type="text" name="member" size="20" value="membership no." maxlength="15" class="clear" /><br />
username desired: <br />
<input type="text" name="username" size="20" maxlength="30" class="clear" value="" /><br />
password desired: <br />
<input type="password" size="20" maxlength="30" name="password" value="" /><br />
<input type="submit" name="update" value="enter" />
</form>Code: Select all
<?
if ( isset( $_POST['update'] ) ) {
if (( $_POST['realname'] == $realname) && ( $POST['member'] == $member)) {
$sql = "UPDATE users SET username='".$_POST['username']."', password='".( $_POST['password'] )."' WHERE member='".$_POST['member']."'";
mysql_query( $sql ) or die( mysql_error( ) );
writeMessage($message);
echo "<meta content="2; url=index.php" http-equiv="refresh">";
}
if (( $_POST['realname'] != $realname) OR ( $POST['member'] != $member)) {
echo "<meta content="0; url=nomatch.php" http-equiv="refresh">";
}
}
?>If the name and/or member have not been entered correctly then it redirects to nomatch.php
If the name and member have been entered correctly the username and password get entered in the db and redirect to index.php
Well that's the idea but it's not working and I can't figure out why.
?>