Results 1 to 6 of 6

Thread: Mailing please help!

  1. #1

    Thread Starter
    Addicted Member Tommy101's Avatar
    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    144

    Mailing please help!

    Hi, i nearly know nothing about php but please look at this very complicated question

    if you go to this address here you will see that the script works fine, all i would like to do is to make it faster. (so i actually don't have to view the page, just type something in the address bar)

    example:
    email.php?.........

    how can i insert the From, To, Subject and Text fields in the address bar?

    It's hard to explain but i hope someone understands what i am saying


    Msn Messenger is the Best

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Mailing please help!

    You can't put the values in the query string becuase the form is submitted via the HTTP post method. It is possible to connect to the server and send a raw HTTP POST request to the page in PHP though.

    It involves the following steps:
    1. Establish a connection to the host on port 80 using the fsockopen() function.
    2. Use the urlencode() function to encode the values of all the variables you are sending via post and construct a string which looks something like this:
      Code:
       name=encoded%20value1&addreess=11%20foster%20road&surname=smith
    3. Find the length of that string using the strlen() function.
    4. Send an HTTP post request using PHP's file I/O functions to the server which will look something like this:
      Code:
       POST /path/topage.php HTTP/1.0
       Content-Length: 63
       Content-Type: application/x-www-form-urlencoded
       
       name=encoded%20value1&addreess=11%20foster%20road&surname=smith
    5. Read back the reponse from the server which should either be:
      Code:
       HTTP/1.0 200 OK
      Code:
       HTTP/1.0 302 FOUND
      Both of these indicate the server recieved the data success fully. The 302 response will come with a location header telling you where to go next and the 200 reposne will come with the page directly after the headers.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    Lively Member Misspell's Avatar
    Join Date
    Mar 2002
    Location
    Located
    Posts
    69

    Re: Mailing please help!

    This should work, its not tested tho...

    Code:
    $recipient = $_GET[st_email] ;
    $subject = $_GET[sub_line] ;
    
    $msg = "Message:". $_GET[message] ."\n\n";
    
    $mailheaders = "Sender Name: Your_Name \n";
    $mailheaders .= "Reply-To: Your_Emial_@_address.com \n\n";
    
    mail($recipient, $subject, $msg, $mailheaders);
    The url would look like...
    [email protected]&sub_line=Subject_Line&message=Body_of_the_message

    There would be no form to fille out, the info would be passed straight to the php file from the url.

    _

    ~ What was once an opinion, became a fact, to be later proven wrong... ~

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Mailing please help!

    Good example Misspell but did you look at the link he gave? I think he wants to use a PHP script to post the data to that server. As it only uses the HTTP post method he would need to do it manually. But maybe a misinterpreted.

    ** Waits for Tommy101 to get back ....
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5
    Lively Member Misspell's Avatar
    Join Date
    Mar 2002
    Location
    Located
    Posts
    69

    Re: Mailing please help!

    Yea i checked out his link, but when he says "so i actually don't have to view the page, just type something in the address bar" i thouhgt he was trying to get around a form lay-out.

    Personaly, i do not see how that would be any faster, if anything more a pain and restricting (typing in a url field), but we're all differnet

    _

    ~ What was once an opinion, became a fact, to be later proven wrong... ~

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Mailing please help!

    Quote Originally Posted by Misspell
    Yea i checked out his link, but when he says "so i actually don't have to view the page, just type something in the address bar" i thouhgt he was trying to get around a form lay-out.

    Personaly, i do not see how that would be any faster, if anything more a pain and restricting (typing in a url field), but we're all differnet

    _
    In PHP you can use the fopen() function to open a web page and read it in to your script similar to what the browser does. If you use a form which sends its data via the GAT method then it is pretty simple as all the form variables and their values are appended to the query string.

    The POST method which the form uses that Tommy pointed to is different, in that the data is sent in the main body of the HTTP request and not in the query string.

    The reason he would use it is to automatically send the data to the server cia his PHP script. I should point out that this does violate the usage policies of some sites and may actually be illegal, so it is worth finding out if you can do it.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width