Server-side Starter Tutorial:Tell-a-Friend - Part 4 of 6

Room for improvement - part 1

Having got the simple script to work, it's time to think in terms of doing something rather more useful with it, as well as adding some error trapping.

OK, so what's next?

One obvious addition would be to get the name and e-mail address of the person filling in the form, and then we could do two things - advise the friend who was responsible, and send a thank you note to the sender.

So, we need a few extra lines in the html form code to gather that information:

Enter your e-mail:  
<input type="text" name="sender_email" size="20" /><br />
Enter your name:  
<input type="text" name="sender_name" size="20" /><br />

And we need to be able to deal with that extra information in the php form. Simple enough - the code we'll need is the bit that abstracts a variable from POSTed data. Below is what needs to be added to our taf.php script:

$sender_email = $_POST['sender_email'];
$sender_name = $_POST['sender_name'];

And we now want to send two e-mails - one to the friend, and one to the sender. This isn't as difficult(?) as you think ....

«  previous  |  next  »  

Site Links

 

Starter Tutorials