only add data 1 time in form
Posted: Tue Apr 13, 2004 3:16 pm
I have this form where user can add there steam_id to the database - I need so that if they allready have add it 1 time - they can`t change it - and better if it tjek the database to see if the number is in use.
I need something like this add to the last code:
I need something like this add to the last code:
Code: Select all
if(($steam_check > 0)){
echo "Please fix the following errors: <br />";
if($steam_check > 0){
echo "The steam_id you have selected has already been used by another member in our database. Please choose a different Username!<br />";
}
exit(); // exit the script so that we do not create this account!
}Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = '../forums/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
init_userprefs($userdata);
//
// End session management
$sqls="SELECT user_pass FROM phpbb_users WHERE user_id='$userdata[user_id]'";
$sql_resultrrr = mysql_query($sqls) or die ("$text_noquery - 1");
$r = mysql_fetch_array($sql_resultrrr);
$user_pass = $r[user_pass];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>steam id</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="liste.css">
</head>
<body>
<h3>Welcome to the steam_id add page <?php echo "$userdata[username]"; ?></h3>
<form method="POST" action="<?php echo "$PHP_SELF"; ?>">
<table>
<tr><td>Steam id:</td><td><input type="text" name="user_pass2" size="30" value="<?php echo "$user_pass"; ?>"></td></tr>
</table>
<input type="submit" value="submit" name="submit" />
<input type="hidden" name="page" value="ter" />
</form>
<div>
<?php
if ($page == ter) {
$sqladd = "UPDATE phpbb_users SET user_pass='$user_pass2' WHERE user_id='$userdata[user_id]'";
$sql_result22 = mysql_query($sqladd) or die ("$text_noquery - ter");
if (!$sql_result22) {
echo "there was an error while submitting the info";
} else {
echo "Info inserted successfully! Click <a href='$PHP_SELF'>here</a> to return to the main page";
}
}
?>
</div>
</body>
</html>
?>