Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: any one help me email this page php code

  1. #1
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default any one help me email this page php code

    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
    HTML Code:
    <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>
    Last edited by Snookerman; 04-21-2009 at 07:57 PM. Reason: added [html] tags

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    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 Code:
    <?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 Code:
    <?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.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Unhappy

    Quote Originally Posted by thetestingsite View Post
    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 Code:
    <?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 Code:
    <?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

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Found the problem and it lies within the following line:

    Code:
    $msg = 'Dear '.$fname',';
    Here is the correction:

    Code:
    $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.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Unhappy

    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

  6. #6
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Quote Originally Posted by sreenivasulareddy View Post
    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"]; ?>

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Code:
    <?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.

    Quote Originally Posted by sreenivasulareddy
    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.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    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!
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  9. #9
    Join Date
    Apr 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  10. #10
    Join Date
    Apr 2009
    Location
    India
    Posts
    41
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    try this .............
    Code:
    <?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.
    
    ?>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •