Gabriele Bartoliniangusgb@t... wrote:
>Ciao Jefferis!
Well, I've overcome some of the hurdles. I changed the escapes to quotemeta.
But I want to autogenerate passwords rather than have to have me manually
do it. This is what I've got so far, but it balks on the UPDATE commands,
which I've tried 2 ways, neither of which work:
> //connect to database
> $con = mysql_connect("db15.pair.com",$user,$password);
>
> if ($con==NULL)
> {
> echo("301 Couldn't connect to MySQL\n\n");
> exit(-1);
> }
>
> $db = mysql_select_db($g_databasename,$con);
>
> $t="insert into users (companyname, contactname, email, baddress1,
>baddress2, bcity,
>bstate, bzip, saddress1, saddress2, scity, sstate, szip, tel, fax,
>active, bcountry, scountry,
>needsvalidation) values (\"%s\",\"%s\
>",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%
>s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",1,\"%s\",\"%s\",1)";
> $sql=sprintf($t, quotemeta($companyname), quotemeta
>($contactname), quotemeta($email), quotemeta($baddress1),
>quotemeta($baddress2), quotemeta($bcity), quotemeta
>($bstate), quotemeta($bzip), quotemeta($saddress1),
>quotemeta($saddress2), quotemeta($scity), quotemeta
>($sstate), quotemeta($szip), quotemeta($tel), quotemeta
>($fax), quotemeta($bcountry), quotemeta($scountry));
>
> //insert user record into database (active ON)
>session_start();
>session_register($contactname);
>$id= substr(md5(uiquid(mt_rand())),1, 5);
>$usname = stripslashes(trim($contactname));
>$username1= substr($usname, 1, 7);
>$username= $username1 + userid;
>$password = $id
>$update="UPDATE users SET username = $username WHERE
>[strval(mysql_insert_id($con))]";
>
>UPDATE users SET password = '[$password]' WHERE
>[strval(mysql_insert_id($con))];
> //debug
> //echo($sql);
> mysql_query($sql,$con);
>
> //send email to user_validator to get them to validate new user.
> $msg = sprintf("A new customer has submitted their information. Log
>into back-end
>database and authorize userid ".strval(mysql_insert_id($con)).". \n\nThis
>can be accomplished
>by setting the \"active\" field (in the table \"users\") to 1. \n\n
>IMPORTANT: You must also set
>their username and password and send it to their email address. The
>username must be
>unique, and both the username and password should be less than 15
>alphanumeric
>characters. Their entered email address is ".$email."\n");
> mail($g_uservalidator_email,"New Customer Submission - Validate",$msg);
--
Jefferis Kent Peterson
www.PetersonSales.net
Flash, Web Design and Marketing
ICQ 19112253
_______
"Happy is the person who finds wisdom, and the one who gets
understanding, for the gain from it is better than gain from silver and
its profit better than gold." - Proverbs 3:13,14.