Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Auto Fill a form from a link
Old 12-24-2009, 04:13 PM Auto Fill a form from a link
Junior Talker

Posts: 3
Trades: 0
Hi all.

I was wondering if anybody could help me I am looking for a way to auto fill a field in a form from a link on a seperate page.

I would like on the FIRST PAGE a link that says 'click here'

And on the SECOND PAGE for it to automaticly fill in a text field on the form.

I have attached the HTML for the form and the PHP that I am using for the form as well


HTML Code:
<form method=post action=tellck.php><table border="0" cellpadding="0" cellspacing="0" align=center><tr bgcolor='#f1f1f1'><td colspan=2 align=center><font face='Verdana' size='2' ><b>TELL A FRIEND</b></font></td></tr><tr><td width=100><font face='Verdana' size='2' >Your Name</font></td><td width=200><input type=text name=y_name></td></tr><tr bgcolor='#f1f1f1'><td><font face='Verdana' size='2' >Your Email</font></td><td><input type=text name=y_email></td></tr><tr ><td><font face='Verdana' size='2' >Your Friend's Name</font></td><td><input type=text name=f_name></td></tr><tr bgcolor='#f1f1f1'><td><font face='Verdana' size='2' >Friend's Email</font></td><td><input type=text name=f_email></td></tr><tr ><td><font face='Verdana' size='2' >Your Message</font></td><td><textarea name=y_msg rows=5 cols=20></textarea></td></tr><tr bgcolor='#f1f1f1'><td colspan=2 align=center><font face='Verdana' size='2' ><input type=submit value='Send'></font></td></tr></table></form>
And the -PHP-

<?
$status = "OK";
$msg="";

$y_email=$_POST['y_email'];
$y_name=$_POST['y_name'];
$f_email=$_POST['f_email'];
$f_name=$_POST['f_name'];
$y_msg=$_POST['y_msg'];


if(substr_count($y_email,"@") > 1 or substr_count($f_email,"@") > 1){
$msg .="Use only one email address<BR>";
$status= "NOTOK";
}

if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $y_email)){ // checking your email
$msg .="Your email address is not correct<BR>";
$status= "NOTOK";}

if (strlen($y_name) <2 ) { // checking your name
$msg .="Please enter your name<BR>";
$status= "NOTOK";}

if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $f_email)) { // checking friends email
$msg .="Your Friends address is not correct<BR>";
$status= "NOTOK";}

if (strlen($f_name) <2 ) { // checking freinds name
$msg .="Please enter your friend's name<BR>";
$status= "NOTOK";}

if (strlen($y_msg) <2 ) { // checking Message details
$msg .="Please enter your message details<BR>";
$status= "NOTOK";}

if(stristr($y_msg,"http://") or stristr($y_msg,"https://") or stristr($y_msg,"<a href") or stristr($y_msg,"http://") or stristr($y_msg,"[url=")){
$msg=$msg."Links or URLs are not allowed <BR>";
$status= "NOTOK";}


if($status=="OK"){ // all validation passed
/////////// Sending the message starts here //////////////
$ref=@$HTTP_REFERER;
/////Message at the top of the page showing the url////
$header_message = "Hi $f_name \n Your friend $y_name requested you to visit the page at \n $ref \n";
/// Body message prepared with the message entered by the user ////
$body_message =$header_message."\n".$y_msg."\n";
$body_message .="\n This is a free script from http://www.plus2net.com";
//// Mail posting part starts here /////////
$headers="";
//$headers = "Content-Type: text/html; charset=iso-8859-1\n".$headers;
// Un comment the above line to send mail in html format
$headers4=$y_email; // Change this to change from address
$headers.="Reply-to: $headers4\n";
$headers .= "From: $headers4\n";
$headers .= "Errors-to: $headers4\n";
$subject="Request to visit URL";
if(mail($f_email,$subject,$body_message,$headers)) {
////// Mail posting ends here ///////////
echo "<center><font face='Verdana' size='2' color=green>Thank You, Your message posted to $f_name</font></center>";
//////////// Sending the message ends here /////////////

}else{
echo "<center><font face='Verdana' size='2' color=red>There is some problem in mail command, contact your host</font></center>";
}

}else{// display the error message
echo "<center><font face='Verdana' size='2' color=red>$msg</font></center>";
}
?>
[/php]

As I say anything would be very greatfully received.

scottmac
scottmac is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-27-2009, 12:52 PM Re: Auto Fill a form from a link
Banned

Posts: 1
Name: holly
Trades: 0
I don't know. I just see this amazing, so I come in to see. looking for the answer.
holly will is offline
Reply With Quote
View Public Profile
 
Old 12-29-2009, 02:39 PM Re: Auto Fill a form from a link
Extreme Talker

Posts: 246
Trades: 0
one word: QueryString

http://ditio.net/2008/06/12/php-query-string/
http://www.homeandlearn.co.uk/php/php4p6.html
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
stbuchok is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Auto Fill a form from a link
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12820 seconds with 12 queries