Current location: Hot Scripts Forums » Programming Languages » PHP » php script to send link in email

php script to send link in email

Reply
  #1 (permalink)  
Old
New Member
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
php script to send link in email

I have a site that allows people to download a program i made, however, i would like to collect there name, email, and phone before they are allowed to download the program. What is the form called that will collect this info and send the download link in a email, or where can i find one?
Reply With Quote

Featured Marketplace Scripts (view more)

  #2 (permalink)  
Old
UnrealEd's Avatar
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 27 Times in 27 Posts
try google for "register form php". you'll find some.

or you could use this (it's a very basic one):
PHP Code:

<?

// open db connection here

if($_POST['submit'] && !empty($_POST['email']) && !empty($_POST['username']) && !empty($_POST['phone'])):

  
$query "INSERT INTO userdata SET username='".$_POST'username']."', email='".$_POST['email']."', phone='".$_POST['phone']."'";
  
mysql_query($query) or die(mysql_error());

  
$to $_POST['email'];
  
$subject "Thank you for registering";
  
$message "Thank you for registering, ".$_POST['username'].",<br><br>here's a link to download the program:<br>
<a href='http://mywebsite.com/program.progextension'>http://mywebsite.com/program.progextension</a>
<br><br>Kind Regards,<br>The webmaster"
;

  
mail($to$subject$message);

  echo 
"an email containing the download link has been sent";

elseif(
$_POST['submit']):
  echo 
"some fields were left blank";
endif;
?>
<html><body>
<form method="post">
Username: <input type="text" name="username"><br>
Phone: <input type="text" name="phone"><br>
Email: <input type="text" name="email"><br>
<input type="submit" name="submit" value="Send"></form>
</body>
</html>
if you're using a database, make sure you have a table called userdata
as i said this is a very basic example: there's no check whether the phone-value contains only numbers, no letters. there's no check for a valid email, and there's no check whether the user allready is registered.

Greetz,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old
New Member
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
how do u use this code to work on an html website.
Reply With Quote
  #4 (permalink)  
Old
UnrealEd's Avatar
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 27 Times in 27 Posts
You can't, you have to have php installed on the server
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #5 (permalink)  
Old
New Member
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
i have a phpbb3 forum all i do is add a link to it on my forum ursite . com / email.php
Reply With Quote
  #6 (permalink)  
Old
New Member
 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation i think is not working

this is the error

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING /user_reg.php on line 7

Quote:
Originally Posted by UnrealEd View Post
try google for "register form php". you'll find some.

or you could use this (it's a very basic one):
PHP Code:

<?

// open db connection here

if($_POST['submit'] && !empty($_POST['email']) && !empty($_POST['username']) && !empty($_POST['phone'])):

  
$query "INSERT INTO userdata SET username='".$_POST'username']."', email='".$_POST['email']."', phone='".$_POST['phone']."'";
  
mysql_query($query) or die(mysql_error());

  
$to $_POST['email'];
  
$subject "Thank you for registering";
  
$message "Thank you for registering, ".$_POST['username'].",<br><br>here's a link to download the program:<br>
<a href='http://mywebsite.com/program.progextension'>http://mywebsite.com/program.progextension</a>
<br><br>Kind Regards,<br>The webmaster"
;

  
mail($to$subject$message);

  echo 
"an email containing the download link has been sent";

elseif(
$_POST['submit']):
  echo 
"some fields were left blank";
endif;
?>
<html><body>
<form method="post">
Username: <input type="text" name="username"><br>
Phone: <input type="text" name="phone"><br>
Email: <input type="text" name="email"><br>
<input type="submit" name="submit" value="Send"></form>
</body>
</html>
if you're using a database, make sure you have a table called userdata
as i said this is a very basic example: there's no check whether the phone-value contains only numbers, no letters. there's no check for a valid email, and there's no check whether the user allready is registered.

Greetz,
UnrealEd
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php script to send and receive sms through kannel gateway sephad Script Requests 0 01-30-06 07:53 AM
PHP script to detach attachment from email jdk Script Requests 1 03-16-05 05:27 PM
PHP Script that lists contents of director + generates download link? eNforcer Script Requests 1 01-15-05 07:01 AM
PHP email script problems (bounces go to wrong address). MTO PHP 1 04-28-04 11:13 PM
PHP script to change URL link weekly hculbert Script Requests 0 01-23-04 03:48 PM


All times are GMT -5. The time now is 06:14 AM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.