[PHP] Can anyone help? PHP script/MySQL problem

2002-12-10 Thread Steven M
Hi, i am trying to create a member login/authentication script to
automatically send newly signed up people an email with a confirmation link.
I am following a tutorial:

http://www.phpfreaks.com/tutorials/40/0.php

My form is located at:

http://www.tricia-marwick.co.uk/members/join_form.php

The script in question is as follows:

 0) || ($username_check > 0)){
  echo "Please fix the following errors: ";
  if($email_check > 0){
   echo "Your email address has already been used

by another member in our database. Please submit a different Email

address!";
   unset($email_address);
  }
  if($username_check > 0){
   echo "The username you have selected has already been

used by another member in our database. Please choose a different

Username!";
   unset($username);
  }
  include 'join_form.php'; // Show the form again!
  exit();  // exit the script so that we do not create this

account!
 }

/* Everything has passed both error checks that we have done.
It's time to create the account! */

/* Random Password generator.
http://www.phpfreaks.com/quickcode/Random_Password_Generator/56.php

We'll generate a random password for the
user and encrypt it, email it and then enter it into the db.
*/

function makeRandomPassword() {
  $salt = "abchefghjkmnpqrstuvwxyz0123456789";
  srand((double)microtime()*100);
   $i = 0;
   while ($i <= 7) {
  $num = rand() % 33;
  $tmp = substr($salt, $num, 1);
  $pass = $pass . $tmp;
  $i++;
   }
   return $pass;
}

$random_password = makeRandomPassword();

$db_password = md5($random_password);

// Enter info into the Database.
$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', '$db_password', '$info2', now())") or die (mysql_error());

if(!$sql){
 echo 'There has been an error creating your account. Please

contact the webmaster.';
} else {
 $userid = mysql_insert_id();
 // Let's mail the user!
 $subject = "Your Membership at RewardPoints!";
 $message = "Dear $first_name $last_name,
 Thank you for registering at our website,

http://www.rewardpoints.net!

 You are two steps away from logging in and accessing our

exclusive members area.

 To activate your membership, please click here:

http://www.tricia-marwick.co.uk/members/activate.php?id=$userid&code=$d

b_password

 Once you activate your memebership, you will be able to login

with the following information:
 Username: $username
 Password: $random_password

 Thanks!
 Steven Marwick

 This is an automated response, please do not reply!";

 mail($email_address, $subject, $message, "From: Steven

Marwick<[EMAIL PROTECTED]>\nX-Mailer: PHP/" . phpversion());
 echo 'Your membership information has been mailed to your email

address! Please check it and follow the directions!';
}

?>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Can anyone help? PHP script/MySQL problem

2002-12-10 Thread Steven M
Hi Rich

The prob is that the data isn't stored into the database as it should be and
the user doesn't get an email back with their data.  It seems to get lost
before reaching the database, meaning the rest of it wont work, and i don't
know why.

Thanks

Steven M



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Can anyone help? PHP script/MySQL problem

2002-12-10 Thread Steven M
Rich,

I'm not getting any error messages.  I have just checked my database and the
only data other than that i manually entered is an auto-increment number and
a random password, which i assume were produced when you filed in the form.
There is no first name, last name, email etc which there should have been if
you filled in the form.

If it was working fine you would recieve an email automatically at the
address you specified.

If you have any ideas what's wrong i'd love to hear them.

Steven M
"Rich Gray" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Any error messages? You say it is not stored 'as it should be' does that
> mean it *is* stored but incorrectly, or is the data just not there?
> FWIW I just used your test form and it said I had registered ok I then
> retried with the same info and I got 2 error messages as I would have
> expected which implies the data is hitting the database ok...
> Rich
>
> -Original Message-
> From: Steven M [mailto:[EMAIL PROTECTED]]
> Sent: 10 December 2002 14:47
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Can anyone help? PHP script/MySQL problem
>
>
> Hi Rich
>
> The prob is that the data isn't stored into the database as it should be
and
> the user doesn't get an email back with their data.  It seems to get lost
> before reaching the database, meaning the rest of it wont work, and i
don't
> know why.
>
> Thanks
>
> Steven M
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] PHP/MySQL Query

2002-12-15 Thread Steven M
How do i make a form that will allow me to add 2 to the value of a MySQL
field?  I am trying to change it from 75 to 77.  Is this possible?

Thanks



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP/MySQL Query

2002-12-15 Thread Steven M
Leif

Many thanks for that, your help is much appreciated.  *smiles*

Steven M



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] PHP/MySQL help?

2003-01-12 Thread Steven M
What am i doing wrong with the script below? What i am trying to do is check
whether the "newtest" field has a 0 or a  1 value then redirect the user to
a different page based on the answer.

I am then trying to add 2 to the value in the "points" field of my database
and then  to set the "newtest" field value to 1 so the user is directed to
the second of the two pages if they click the link again

My database is MySQL and the connection details are correct and stored in an
external script.  I have missed out the PHP tags on the code below in case
that interferes with how it appears on the list.  I really would appreciate
any help with this as i am a newbie to MySQL and PHP and am finding it a
really steep learning curve.  Thanks.

Steven M
---
include 'db.php';

$result = mysql_query("SELECT newtest FROM users WHERE 14 = '$0'");
list($number) = mysql_fetch_row($result);
mysql_close();

if($number==0)
{mysql_query("UPDATE users SET points = '$+2' WHERE 14 = '$0'");
mysql_query("UPDATE users SET newtest = '$1' WHERE newtest = '$0'");
header("Location: redirect1.php");
}
elseif($number==1)
{
header("Location: redirect2.php");
}
else
{
header("Location: error.php");
}
---




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP/MySQL help?

2003-01-12 Thread Steven M
Hi Johannes

Thanks for the help.  I have taken out the mysql_close() and it looks like
it is submitting ok (ie no error messages) but it is not updating the
database when i check it.  Any ideas?

Thanks.

Steven
"Johannes Schlueter" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Hi Steven,

On Sunday 12 January 2003 23:58, Steven M wrote:
> include 'db.php';
>
> $result = mysql_query("SELECT newtest FROM users WHERE 14 = '$0'");
> list($number) = mysql_fetch_row($result);

Here you are closing your conenction to the MySQL-Server:
> mysql_close();

> if($number==0)

But here you need it again:
> {mysql_query("UPDATE users SET points = '$+2' WHERE 14 = '$0'");
> mysql_query("UPDATE users SET newtest = '$1' WHERE newtest = '$0'");

So remove the mysql_close() if it don't work: Post the error message!

johannes



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP/MySQL help?

2003-01-12 Thread Steven M
I thought i read somewhere that you could refer to the field by number.  Was
i wrong? It doesn't seem to make a difference anyway.  It still doesn't
work.  Here's the code with words instead of numbers.  I'd be grateful if
you could let me know if there are any obvious errors.

Best wishes.

Steven M

include 'db.php';

$result = mysql_query("SELECT newtest FROM users WHERE newtest = '$0'");
list($number) = mysql_fetch_row($result);

if($number==0)
{mysql_query("UPDATE users SET points = '$+2' WHERE newtest = '$0'");
mysql_query("UPDATE users SET newtest = '$1' WHERE newtest = '$0'");
header("Location: redirect1.php");
}
elseif($number==1)
{
header("Location: redirect2.php");
}
else
{
header("Location: error.php");
}



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP/MySQL help?

2003-01-12 Thread Steven M
Oops...many thanks for that.  Sorry, i am extremely new to this.

Best wishes.

Steven M



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] PHP form help

2003-02-19 Thread Steven M
Hi,

I have created a form that passes details to the next page so the user can
see the details they have submitted before clicking confirm to submit to the
database.  The problem is that the details dont seem to get passed to the
script after they have appeared on the confirmation page.  I know the script
works because i submitted info to is successfully before i changed the form
action to point at the confirmation page.

I think it has something to do with PHP sessions but am not sure how to make
it work.  Thanks for any help.

Steven M





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP form help

2003-02-19 Thread Steven M
Hi Johnathan

Thanks I've got it now, hidden fields did the trick. :-)

Steven M
"Jonathan Villa" <[EMAIL PROTECTED]> wrote in message
004301c2d851$24ac2fd0$8600a8c0@inhocvince">news:004301c2d851$24ac2fd0$8600a8c0@inhocvince...
> How is the information being kept?  Sessions?  You'll either want to
> store them in a session or create hidden fields on the confirmation
> page, then when they click on confirm, you'll have access to the fields
> on the new page, (the page where your processing script is)
>
>
> ---> Jonathan
>
>
>
>
> -Original Message-
> From: Steven M [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 19, 2003 2:15 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] PHP form help
>
> Hi,
>
> I have created a form that passes details to the next page so the user
> can
> see the details they have submitted before clicking confirm to submit to
> the
> database.  The problem is that the details dont seem to get passed to
> the
> script after they have appeared on the confirmation page.  I know the
> script
> works because i submitted info to is successfully before i changed the
> form
> action to point at the confirmation page.
>
> I think it has something to do with PHP sessions but am not sure how to
> make
> it work.  Thanks for any help.
>
> Steven M
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP form help

2003-02-19 Thread Steven M
Thanks Ray but i've found the problem and sorted it.  :-)

Steven M



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php