Ask a Question related to PHP Development, Design and Development.
-
Allan Hugo #1
DB User authentication.
Not a programmin newbie, but a PHP newbie.
I'm working off the user authentication and database thing off
hotscripts.com.
It doesn't work, yet from what I can see, it should.
Maybe I've done something wrong (no wait... obviously I've done something
wrong)
Any help?
Here are the contents of the relevant files:
INDEX.HTML:
<form name="form1" method="post" action="register.php">
<p>First Name
<input name="first_name" type="text" id="first_name" value="">
<br>
Last Name
<input type="text" name="last_name" value="">
<br>
Email Address:
<input type="text" name="email_address" value="">
<br>
Username:
<input type="text" name="username" value="">
<br>
Info:
<textarea name="info"></textarea>
<br>
<input type="submit" name="Submit" value="Join">
</p>
</form>
REGISTER.PHP
<?
include 'db.php';
//define variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$info = $_POST['info'];
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$info = stripslashes($info);
echo $first_name . "<br>";
echo $last_name . "<br>";
echo $email_address . "<br>";
echo $username . "<br>";
echo $info . "<br>";
/* if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
echo 'You did not submit the following required information! <br />';
if(!$first_name){
echo "First Name is a required field. Please enter it below.<br />";
}
if(!$last_name){
echo "Last Name is a required field. Please enter it below.<br />";
}
if(!$email_address){
echo "Email Address is a required field. Please enter it below.<br
/>";
}
if(!$username){
echo "Desired Username is a required field. Please enter it
below.<br />";
}
include 'index.html'; // Show the form again!
exit(); // if the error checking has failed, we'll exit the script!
}*/
$sql_email_check = mysql_query("SELECT email_address FROM users WHERE
email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM users WHERE
username='$username'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if($email_check > 0 || $username_check > 0) {
echo "There were some errors: <br>";
if($email_check > 0) {
echo "email taken";
unset($email_address);
}
if($username_check > 0) {
echo "username taken";
unset($username);
}
include 'index.html';
exit();
}
function makeRandomPassword() {
$salt = "abcdefghijklmnopqrstuvwxyz1234567890";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pas = $pass . $tmp;
$i++
}
return $pass;
}
$random_password = makeRandomPassword();
$db_password = md5($random_password);
$info2 = htmlspecialchars($info);
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address,
username, password, info, signup_date) VALUES ('$first_name, $last_name,
$email_address, $username, $password, $info2, now())" or die
(mysql_error());
if ($sql) {
echo "bugger";
} else {
$userid = mysql_insert_id();
$subject = "membership, foo";
$message = "Dear $first_namae $last_name,
To activate you membership, click here:
[url]http://[[/url][domain]]/dbtest/activate.php?id=$userid&code=$db_password
Thanks!";
mail($email_address, $subject, $message, 'From: Yep-MM test Server\n
X-Mailer: PHP/' . phpversion());
echo "Done.";
}
?>
DB.PHP
<?
$hostname = "localhost";
$database = "[[dbname]]";
$username = "[[username]]";
$password = "[[password]]";
$connection = mysql_pconnect($hostname, $username, $password) or
die(mysql_error());
?>
Allan Hugo Guest
-
user authentication weirdness
On our development machine, running MySQL 5.0.19, I created a database alert_db, and for development purposes created a user called alert_db with a... -
User Authentication
Hi All: I would like to have certain areas of a site that I am developing password protected but I am not sure how to go about doing this. I know... -
User Authentication problems
hi everyone i am using a php site and i have been trying to implement user authentication by completing the macromedia tutorial "Macromedia -... -
XP user authentication
Folks, Given the following function signature: bool AutheticateUser(string uid, string pwd); Can anyone tell me which .Net class.function API... -
SQL User authentication
Is it possible to authenticate user using a SQL database, containing users and passwords? What I want to achive is: I have as SQL database... -
Shawn Wilson #2
Re: DB User authentication.
Allan Hugo wrote:
What do you mean by "doesn't work"? Please describe any error messages you're>
> Not a programmin newbie, but a PHP newbie.
>
> I'm working off the user authentication and database thing off
> hotscripts.com.
>
> It doesn't work, yet from what I can see, it should.
>
> Maybe I've done something wrong (no wait... obviously I've done something
> wrong)
>
> Any help?
> Here are the contents of the relevant files:
>
> INDEX.HTML:
> <form name="form1" method="post" action="register.php">
> <p>First Name
> <input name="first_name" type="text" id="first_name" value="">
> <br>
> Last Name
> <input type="text" name="last_name" value="">
> <br>
> Email Address:
> <input type="text" name="email_address" value="">
> <br>
> Username:
> <input type="text" name="username" value="">
> <br>
> Info:
> <textarea name="info"></textarea>
> <br>
> <input type="submit" name="Submit" value="Join">
> </p>
> </form>
>
> REGISTER.PHP
>
> <?
> include 'db.php';
>
> //define variables
> $first_name = $_POST['first_name'];
> $last_name = $_POST['last_name'];
> $email_address = $_POST['email_address'];
> $username = $_POST['username'];
> $info = $_POST['info'];
>
> $first_name = stripslashes($first_name);
> $last_name = stripslashes($last_name);
> $email_address = stripslashes($email_address);
> $username = stripslashes($username);
> $info = stripslashes($info);
>
> echo $first_name . "<br>";
> echo $last_name . "<br>";
> echo $email_address . "<br>";
> echo $username . "<br>";
> echo $info . "<br>";
>
> /* if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
> echo 'You did not submit the following required information! <br />';
> if(!$first_name){
> echo "First Name is a required field. Please enter it below.<br />";
> }
> if(!$last_name){
> echo "Last Name is a required field. Please enter it below.<br />";
> }
> if(!$email_address){
> echo "Email Address is a required field. Please enter it below.<br
> />";
> }
> if(!$username){
> echo "Desired Username is a required field. Please enter it
> below.<br />";
> }
> include 'index.html'; // Show the form again!
> exit(); // if the error checking has failed, we'll exit the script!
> }*/
>
> $sql_email_check = mysql_query("SELECT email_address FROM users WHERE
> email_address='$email_address'");
> $sql_username_check = mysql_query("SELECT username FROM users WHERE
> username='$username'");
>
> $email_check = mysql_num_rows($sql_email_check);
> $username_check = mysql_num_rows($sql_username_check);
>
> if($email_check > 0 || $username_check > 0) {
> echo "There were some errors: <br>";
> if($email_check > 0) {
> echo "email taken";
> unset($email_address);
> }
> if($username_check > 0) {
> echo "username taken";
> unset($username);
> }
> include 'index.html';
> exit();
> }
>
> function makeRandomPassword() {
> $salt = "abcdefghijklmnopqrstuvwxyz1234567890";
> srand((double)microtime()*1000000);
> $i = 0;
> while ($i <= 7) {
> $num = rand() % 33;
> $tmp = substr($salt, $num, 1);
> $pas = $pass . $tmp;
> $i++
> }
> return $pass;
> }
>
> $random_password = makeRandomPassword();
>
> $db_password = md5($random_password);
>
> $info2 = htmlspecialchars($info);
> $sql = mysql_query("INSERT INTO users (first_name, last_name, email_address,
> username, password, info, signup_date) VALUES ('$first_name, $last_name,
> $email_address, $username, $password, $info2, now())" or die
> (mysql_error());
>
> if ($sql) {
> echo "bugger";
> } else {
> $userid = mysql_insert_id();
> $subject = "membership, foo";
> $message = "Dear $first_namae $last_name,
> To activate you membership, click here:
> [url]http://[[/url][domain]]/dbtest/activate.php?id=$userid&code=$db_password
> Thanks!";
> mail($email_address, $subject, $message, 'From: Yep-MM test Server\n
> X-Mailer: PHP/' . phpversion());
> echo "Done.";
> }
> ?>
>
> DB.PHP
> <?
> $hostname = "localhost";
> $database = "[[dbname]]";
> $username = "[[username]]";
> $password = "[[password]]";
> $connection = mysql_pconnect($hostname, $username, $password) or
> die(mysql_error());
> ?>
getting, or other indications that it is not working correctly.
Shawn
--
Shawn Wilson
[email]shawn@glassgiant.com[/email]
[url]http://www.glassgiant.com[/url]
Shawn Wilson Guest
-
Allan Hugo #3
Re: DB User authentication.
"Shawn Wilson" <shawn@glassgiant.com> wrote in message
news:3FA67685.294A0C9D@glassgiant.com...something> Allan Hugo wrote:> >
> > Not a programmin newbie, but a PHP newbie.
> >
> > I'm working off the user authentication and database thing off
> > hotscripts.com.
> >
> > It doesn't work, yet from what I can see, it should.
> >
> > Maybe I've done something wrong (no wait... obviously I've done> <snip>> > wrong)
> >
> > Any help?you're> What do you mean by "doesn't work"? Please describe any error messageswhat do i mean by 'doesn't work'?> getting, or other indications that it is not working correctly.
well i get a white page...
Allan Hugo Guest
-
iGadget #4
Re: DB User authentication.
On Tue, 04 Nov 2003 00:07:26 GMT, Allan Hugo wrote:
what do i mean by 'try and help yourself a little more'?>
> "Shawn Wilson" <shawn@glassgiant.com> wrote in message
> news:3FA67685.294A0C9D@glassgiant.com...> something>> Allan Hugo wrote:>>>
>>> Not a programmin newbie, but a PHP newbie.
>>>
>>> I'm working off the user authentication and database thing off
>>> hotscripts.com.
>>>
>>> It doesn't work, yet from what I can see, it should.
>>>
>>> Maybe I've done something wrong (no wait... obviously I've done>>> <snip>>>> wrong)
>>>
>>> Any help?> you're>> What do you mean by "doesn't work"? Please describe any error messages>>> getting, or other indications that it is not working correctly.
> what do i mean by 'doesn't work'?
>
> well i get a white page...
Try using the same debug process that you do in any other language.
Add some echo commands to see where the process is failing, and ask
something a little more specific than "please debug my whole program" :)
Cheers,
iGadget
iGadget Guest
-
David Robley #5
Re: DB User authentication.
In article <9Tppb.176838$bo1.114413@news-server.bigpond.net.au>,
[email]someone@microsoft.com[/email] says...Can you be a little more specific about 'doesn't work' - do you mean it> Not a programmin newbie, but a PHP newbie.
>
> I'm working off the user authentication and database thing off
> hotscripts.com.
>
> It doesn't work, yet from what I can see, it should.
lays on the couch all day drinking beer? Or is there some sort of error
message? Or...
<SNIP> lots of code> Maybe I've done something wrong (no wait... obviously I've done something
> wrong)
>
> Any help?
> Here are the contents of the relevant files:
>
> INDEX.HTML:
As a debugging aid, you might consider using mysql_error after all calls
to the db, and also echo your queries to ensure you are submitting the
query you think you are.
Cheers
--
Quod subigo farinam
$email =~ s/oz$/au/o;
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?
David Robley Guest



Reply With Quote

