Ok, I read in the man about the htmlentilies() I don't understand what this does for my data that fills the form fields, please explain so I can understand this better.
ok the '' around the email_address is fixed, I copy this from another thing I had done for a update set thing I think, but its fixed
I will take care of the vulnerable stuff also sometime soon (morning :-) )
Yes I have a index on the email_address and I have also now taken out the select query (leaves me a little confused of how I can check if account exist before creating a user id) I will read the mysql man and find out wha the error code is
I no longer have that select statement so thats fixed :-) or less I missed one I have a mysql_num_rows for the while loop, should I change that to the $results_s var?
I want the user_id to have P- (person) in them and E- (entitie) W- (web) any ideas of how to do this a better way would be great :-) .
I will delete all mysql_error() things once I know the script is safe and also ready to be put in live mode
are you talking about the activation and access_... tables? if so I did not think about that and the three fields thats in the activation table get deleted after the activation process as this is at that time no longer useful activation code, activation expire date and then the user_id that says what account the activation code for
wow lots of things, I am learning through!
below is the new script:
Sincerely,
Christopher
Could I do what I did with the escaping in the area with the hidden form or should I do it in the querys?
<?php
if(isset($_POST['next']))
{
$salt = "123abc123abccba321cba321";
$_POST['user_password'] = md5($salt . $_POST['user_password'] . $salt);
$_POST['verify_user_password'] = md5($salt . $_POST['verify_user_password'] . $salt);
echo '
<form action ="create_account.php" method="post">
<input type="hidden" value="\". mysql_real_escape_string($_POST['f_name']) .\"" id="f_name" name="f_name" />
<input type="hidden" value="\". mysql_real_escape_string($_POST['m_inital']) .\"" id="m_inital" name="m_inital" />
<input type="hidden" value="\". mysql_real_escape_string($_POST['l_name']) .\"" id="l_name" name="l_name" />
<input type="hidden" value="\". mysql_real_escape_string($_POST['email_address']) .\"" id="email_address" name="email_address" />
<input type="hidden" value="\". mysql_real_escape_string($_POST['user_password']) .\"" id="user_password" name="user_password" />
<input type="hidden" value="\". mysql_real_escape_string($_POST['verify_user_password']) .\"" id="verify_user_password" name="verify_user_password" />
<p>PLease look at the information and make sure its correct!</p>
'. $_POST['f_name'] .' '. $_POST['m_inital'] .' '. $_POST['l_name'] .'<br />'. $_POST['email_address'].'<br /><br />
<input type="submit" name="create" value="Create Account" />
</form>
';
}
else if(isset($_POST['create']))
{
include '/home/dev/www/lib/db_config_cr-dev.php';
include '/home/dev/www/lib/db_conn-select.php';
do {
$user_id = sprintf("%'09d", mt_rand(1, 999999999));
$user_id = "P-".$user_id;
$query_s = "SELECT user_id FROM access_credentials WHERE user_id = '$user_id'";
$result_s = mysql_query($query_s) OR die("Sorry, unable to select record: " . mysql_error());
echo $user_id .'<br />';
}
while(mysql_num_rows($result_s) != 0); // don't do again if = 0
$salt = "123abc123abccba321cba321";
$_POST['user_password'] = md5($salt . $_POST['user_password'] . $salt);
$query_i = "INSERT INTO user_info (user_id, f_name, m_inital, l_name, email_address) VALUES ('$user_id', '$_POST[f_name]','$_POST[m_inital]','$_POST[l_name]','$_POST[email_address]')";
$result_i = mysql_query($query_i) OR die("Sorry was unable to create account (not able to insert into the database table! <br />" . mysql_error());
$count = mysql_affected_rows();
if($count)
{
$query_i = "INSERT INTO access_credentials (user_id, user_password, user_access_level) VALUES ('$user_id', '$_POST[user_password]','0')";
$result_i = mysql_query($query_i) OR die("Sorry was unable to insert ".$fin." into the database table allowed! <br />" . mysql_error());
$count = mysql_affected_rows();
if($count)
{
include "/home/dev/www/lib/random.php";
$activation_code = strtoupper(random(10));
$expire_date = strtotime("+3 days");
$query_i = "INSERT INTO activation (user_id, activation_code, expire_date) VALUES ('$user_id', '$activation_code','$expire_date')";
$result_i = mysql_query($query_i) OR die("Sorry was unable to insert ".$fin." into the database table allowed! <br />" . mysql_error());
$count = mysql_affected_rows();
if($count)
{
echo "Account Created";
$expire_date = date( "Y-m-d", $expire_date);
include '/home/dev/www/user-sys/create_account_activation_email.php';
header("location: activate.php");
}
else
{
echo "We had a problem adding your account ERROR: 1012";
}
}
else
{
echo "We had a problem adding your account ERROR: 1011";
}
}
else
{
echo "We had a problem adding your account ERROR: 1010";
}
}
else
{
include '/home/dev/www/user-sys/create_account_form.php';
}
?>