Log in

View Full Version : any one help me email this page php code



sreenivasulareddy
12-13-2006, 12:07 PM
hi Friends
i need email this page(tell to friend) php code Bez i no for normal feed back form code but idont how to get send the url plz help me

this is my html form

<form name="contact" method="POST" action="sendurl.php" onSubmit="return valider()">
<table width="500" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="214" align="right">
Your Name: </td>
<td ><input type="text" name="visitor" size="25"></td>
</tr>
<tr>
<td align="right">Your Email:</td>
<td><input type="text" name="visitormail" size="25"></td>
</tr>
<tr>
<td align="right">Friend's Name: </td>
<td><input type="text" name="friend" size="25"></td>
</tr>
<tr>
<td align="right">Friend's Email: </td>
<td><input type="text" name="friendmail" size="25"></td>
</tr>
<tr>
<td align="right">Your Message:<br> <br> </td>
<td><textarea name=notes rows=4 cols=27></textarea></td>
</tr>
<tr align="center">
<td height="30" colspan="2">
<input name="Submit" type="submit" value="Send URL">
</td>
</tr>
</table>
</form>

thetestingsite
12-14-2006, 01:23 AM
if the above code was in a php page, you could add a hidden form field (let's call it url), then in the value place this



<?php echo $_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]; ?>


That will display the full url of the webpage the user is viewing.

After that, make the php page (lets call it "sendurl.php"). Below is a template of that.



<?php

//request all data from html form and assign variables for them

$vname = $_REQUEST[visitor];
$vemail = $_REQUEST[visitormail];
$fname = $_REQUEST[friend];
$femail = $_REQUEST[friendmail];
$message = $_REQUEST[notes];
$url = $_REQUEST[url];

$to = $femail;

$subject = "Check out this webpage";

$msg = 'Dear '.$fname',';
$msg .= $vname.' has sent a webpage link for you to see, and they also sent a message. The url to the webpage is '.$url.' and the message is below!';
$msg .= ' ';
$msg .= $message;

$from = $vname.' <'.$vemail.'>';

mail($to, $subject, $msg, $from); //send the message

header('Location: '.$url); //redirect user to page they were at.

?>


I haven't tested this out, but I have wrote something like this before. Let me know if you need any more help.

sreenivasulareddy
12-14-2006, 04:03 AM
if the above code was in a php page, you could add a hidden form field (let's call it url), then in the value place this



<?php echo $_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]; ?>


That will display the full url of the webpage the user is viewing.

After that, make the php page (lets call it "sendurl.php"). Below is a template of that.



<?php

//request all data from html form and assign variables for them

$vname = $_REQUEST[visitor];
$vemail = $_REQUEST[visitormail];
$fname = $_REQUEST[friend];
$femail = $_REQUEST[friendmail];
$message = $_REQUEST[notes];
$url = $_REQUEST[url];

$to = $femail;

$subject = "Check out this webpage";

$msg = 'Dear '.$fname',';
$msg .= $vname.' has sent a webpage link for you to see, and they also sent a message. The url to the webpage is '.$url.' and the message is below!';
$msg .= ' ';
$msg .= $message;

$from = $vname.' <'.$vemail.'>';

mail($to, $subject, $msg, $from); //send the message

header('Location: '.$url); //redirect user to page they were at.

?>


I haven't tested this out, but I have wrote something like this before. Let me know if you need any more help.



Hi Friend

Thank Q for helping

Iam testing the ur php codde

but there is coming this error

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in D:\Inetpub\IAE_TEST\sendurl.php on line 39

thetestingsite
12-14-2006, 04:18 AM
Found the problem and it lies within the following line:



$msg = 'Dear '.$fname',';


Here is the correction:



$msg = 'Dear '.$fname.',';


After that, it works. Sorry, I didn't proofread before submitting. Let me know if you need any further help, or experience any other problems with the code.

sreenivasulareddy
12-14-2006, 08:46 AM
HI friend

I got this message

Notice: Use of undefined constant visitor - assumed 'visitor' in D:\Inetpub\IAE_TEST\sendurl.php on line 28

Notice: Use of undefined constant visitormail - assumed 'visitormail' in D:\Inetpub\IAE_TEST\sendurl.php on line 29

Notice: Use of undefined constant friend - assumed 'friend' in D:\Inetpub\IAE_TEST\sendurl.php on line 30

Notice: Use of undefined constant friendmail - assumed 'friendmail' in D:\Inetpub\IAE_TEST\sendurl.php on line 31

Notice: Use of undefined constant notes - assumed 'notes' in D:\Inetpub\IAE_TEST\sendurl.php on line 32

Notice: Use of undefined constant url - assumed 'url' in D:\Inetpub\IAE_TEST\sendurl.php on line 33

Notice: Undefined index: url in D:\Inetpub\IAE_TEST\sendurl.php on line 33

Warning: Cannot modify header information - headers already sent by (output started at D:\Inetpub\IAE_TEST\sendurl.php:2) in D:\Inetpub\IAE_TEST\sendurl.php on line 48



and iam receaving the mail but iam not receaing the any link i got the only message that message is

Dear cvxvc,hi has sent a webpage link for you to see, and they also sent a message. The url to the webpage is and the message is below! vvxxv


There is no link dispalyed

sreenivasulareddy
12-14-2006, 08:47 AM
Hi Friend

Thank Q for helping

Iam testing the ur php codde

but there is coming this error

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in D:\Inetpub\IAE_TEST\sendurl.php on line 39
where is added this php code this is addin email this page.html file or
sendurl php file
can u plz tell me the information


<?php echo $_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]; ?>

thetestingsite
12-15-2006, 02:06 AM
<?php echo $_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]; ?>


The above should be added to your html form only if it is a PHP file. Otherwise, you will have to make place the link in a hidden field manually.



Notice: Use of undefined constant visitor - assumed 'visitor' in D:\Inetpub\IAE_TEST\sendurl.php on line 28

Notice: Use of undefined constant visitormail - assumed 'visitormail' in D:\Inetpub\IAE_TEST\sendurl.php on line 29

Notice: Use of undefined constant friend - assumed 'friend' in D:\Inetpub\IAE_TEST\sendurl.php on line 30

Notice: Use of undefined constant friendmail - assumed 'friendmail' in D:\Inetpub\IAE_TEST\sendurl.php on line 31

Notice: Use of undefined constant notes - assumed 'notes' in D:\Inetpub\IAE_TEST\sendurl.php on line 32

Notice: Use of undefined constant url - assumed 'url' in D:\Inetpub\IAE_TEST\sendurl.php on line 33

Notice: Undefined index: url in D:\Inetpub\IAE_TEST\sendurl.php on line 33

Warning: Cannot modify header information - headers already sent by (output started at D:\Inetpub\IAE_TEST\sendurl.php:2) in D:\Inetpub\IAE_TEST\sendurl.php on line 48


As for all of that, you may need to place the $_REQUEST[blahblah] in quotes. So it would look like the following:

$NAME = $_REQUEST["name"];

($NAME is the variable to be used in the php script, and name (lowercase inside the request) is the form field name being assigned to that variable, if that makes sense.

The variables in the php code I have added were in the original code that you posted (the html form).

Hope this helps, but let me know if it doesn't.

thetestingsite
12-15-2006, 02:23 AM
If you would like a working example, visit http://www.thetestingsite.net/test/ and click on either test1.php or send_test2.php to view it. After you are done testing it, view the source of each page by clicking on the filename with the phps extension. That will show you the source codes of all of the pages involved in the example.

Enjoy!

MediaGearhead
04-21-2009, 07:51 PM
If i could throw in my 2 cents I would recommend modifying the line that pulls in the message to this.

$message = stripslashes($_REQUEST[notes]);

This is only necessary if you are using magic_quotes

Love the script thanks thetestingsite :)

amutha
04-22-2009, 09:53 AM
try this ............. :)

<?php

//request all data from html form and assign variables for them

$vname = $_REQUEST['visitor'];
$vemail = $_REQUEST['visitormail'];
$fname = $_REQUEST['friend'];
$femail = $_REQUEST['friendmail'];
$message = $_REQUEST['notes'];
$url = $_REQUEST['url'];

$to = $femail;

$subject = "Check out this webpage";

$msg = "Dear $fname";
$msg .= $vname.' has sent a webpage link for you to see, and they also sent a message. The url to the webpage is '.$url.' and the message is below!';
$msg .= ' ';
$msg .= $message;

$from = $vname.' <'.$vemail.'>';

mail($to, $subject, $msg, $from); //send the message

header('Location: '.$url); //redirect user to page they were at.

?>

Schmoopy
04-23-2009, 12:38 AM
Maybe you're a bit late with the reply - this thread was started 3 years ago. I suppose your code could be helpful to anyone who has a similar problem, but the original poster is probably long gone.