1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP help please

Discussion in 'PHP & Perl' started by Knoxgates, Sep 8, 2009.

  1. Knoxgates

    Knoxgates Supreme Member

    Joined:
    Aug 9, 2008
    Messages:
    1,266
    Likes Received:
    918
    Hi,

    I download this script from sourceforge and i want to edit it, But i m not familiar with HTML or PHP. can anybody help

    Html form:
    mail.php
    The HTML form contains fields Name,Email Address and message fields. But i want First Name, Last Name, And Email Address fields instead of that.

    Can anybody edit this code. so that i m able to run this script.
     
    • Thanks Thanks x 1
  2. rnc505

    rnc505 Regular Member

    Joined:
    Oct 28, 2008
    Messages:
    229
    Likes Received:
    109
    New code:

    html form
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    ?http://www.w3.org/TR/html4/strict.dtd?> 
    <html>
    <head> 
    <title>A simple form</title> 
    </head> 
    <body>
    <h1>A form</h1>
    <form action=?mail.php? method=?post?> 
    <label for=?firstn?>First Name:</label><br> 
    <input type=?text? name=?first? id=?firstn?><br> 
    <label for=?lastn?>Last Name:</label><br> 
    <input type=?text? name=?last? id=?lastn?><br> 
    <label for=?emaila?>Email Address:</label><br> 
    <input type="text" name=?email? id=?emaila?></input><br> 
    <input type=?submit? value=?send?> 
    </form> 
    </body>
    </html>
    
    mail.php
    PHP:
    <?php 
    //enter the address to send the form to 
    $toAddress = ?someone@somewhere.com?; 
    //enter the subject of the email you recieve
    $subject = ?Contact from Web?;
    //enter the path to the file where the user gets sent to after submitting the form
    $thankYou = ?thanks.php?; 
    $first $_REQUEST['first']; 
    $last $_REQUEST['last'];
    $email $_REQUEST['email'];
    $body = ? 
    First Name$first\n\
    Last Name
    $last\n\n
    Email Address
    $email?; 
    mail($toAddress$subject$body, ?From$email?);
    header(?Location$thankYou?);
    ?>
    Good Luck with your project!


    __________________
     
    • Thanks Thanks x 3
  3. Daylight

    Daylight BANNED BANNED

    Joined:
    Jul 12, 2009
    Messages:
    52
    Likes Received:
    8
    I also needed a script like this. Thx bro...
     
  4. Zicky

    Zicky Registered Member

    Joined:
    Mar 7, 2009
    Messages:
    75
    Likes Received:
    14
    Location:
    No Clue
    Thanks for the script,
    How can i fix the "Submit button" and make it send an email to the email address i enter on mail.php?
    And if its possible after somoene submit the email address, there will be some pop up message says thanks for submit.
     
  5. iPwnJ00

    iPwnJ00 Junior Member

    Joined:
    Mar 10, 2009
    Messages:
    132
    Likes Received:
    21
    Location:
    Melbourne, Australia
    There's a typo in the PHP file?

    Code:
    [COLOR=#000000][COLOR=#0000bb]First Name[/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000bb]$firstnn 
    
    Last Name[/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000bb]$lastnn
    
    Email Address[/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000bb]$email"[/COLOR][COLOR=#007700]; 
    [/COLOR][/COLOR]


    But above that you specified:

    Code:
    [COLOR=#000000][COLOR=#0000bb]$first [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]$_REQUEST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'first'[/COLOR][COLOR=#007700]]; 
    
    [/COLOR][COLOR=#0000bb]$last [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]$_REQUEST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'last'[/COLOR][COLOR=#007700]];
    
    [/COLOR][COLOR=#0000bb]$email [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]$_REQUEST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'email'[/COLOR][COLOR=#007700]];
    [/COLOR][/COLOR]






    Therefore, I believe the correct code should be:

    Code:
    [COLOR=#000000][COLOR=#0000bb]First Name[/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000bb]$first
    
    Last Name[/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000bb]$last
    
    Email Address[/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000bb]$email"[/COLOR][COLOR=#007700];[/COLOR][/COLOR]
    

     
  6. iPwnJ00

    iPwnJ00 Junior Member

    Joined:
    Mar 10, 2009
    Messages:
    132
    Likes Received:
    21
    Location:
    Melbourne, Australia
    I'll help if you have any troubles; feel free to PM me. I'm just a bit busy right now.

    The current PHP script should send an email to the address that you specified, but that's only if the mail() function is enabled by your web host, which normally, it is, unless the company wants to reduce spam. You could try contacting them.

    Secondly, to show them a 'Thanks....' page, you could either:

    Put ' echo "Thanks for registering!"; ' on the bottom of your PHP file

    OR

    Do a meta-refresh/redirection to a new page on the bottom of the PHP file.
     
  7. Zicky

    Zicky Registered Member

    Joined:
    Mar 7, 2009
    Messages:
    75
    Likes Received:
    14
    Location:
    No Clue
    So how the mail.php file should look like?


    Can't test the Thanks things since there is no Submit button.
    [​IMG]
    How can i fix the Submit Button?

    And i think my host provide the email thing, got the full script for that?

    Thanks.
     
  8. iPwnJ00

    iPwnJ00 Junior Member

    Joined:
    Mar 10, 2009
    Messages:
    132
    Likes Received:
    21
    Location:
    Melbourne, Australia
    Code:
    <?php 
    
    //enter the address to send the form to 
    
    $toAddress = "someone@somewhere.com"; 
    
    //enter the subject of the email you recieve
    
    $subject = "Contact from Web";
    
    //enter the path to the file where the user gets sent to after submitting the form
    
    $thankYou = "thanks.php"; 
    
    $first = $_REQUEST['first']; 
    
    $last = $_REQUEST['last'];
    
    $email = $_REQUEST['email'];
    
    $body = " 
    
    First Name: $first
    
    Last Name: $last
    
    Email Address: $email"; 
    
    mail($toAddress, $subject, $body, "From: $email");
    
    header("Location: $thankYou");
    
    ?>
    That's the PHP file.


    The HTML has quite a few typos. I'll make you a new one in a bit.
     
    • Thanks Thanks x 1
  9. iPwnJ00

    iPwnJ00 Junior Member

    Joined:
    Mar 10, 2009
    Messages:
    132
    Likes Received:
    21
    Location:
    Melbourne, Australia
    Okay, the HTML file:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>A simple form</title>
    </head>
    <body>
    <h1>A form</h1>
    
    <form id="form1" name="form1" method="post" action="mail.php">
          <label>First Name:
            <input type="text" name="first" id="first" />
          </label>
          <br />
          <label>Last Name:
            <input type="text" name="last" id="last" />
          </label>
          <br />
      <label>Email Address:
            <input type="text" name="email" id="email" />
          </label>
        <p>
          <label>
            <input type="submit" name="submit" id="submit" value="Submit" />
          </label>
        </p>
    </form>
    </body>
    </html>
    
     
    • Thanks Thanks x 1
  10. Zicky

    Zicky Registered Member

    Joined:
    Mar 7, 2009
    Messages:
    75
    Likes Received:
    14
    Location:
    No Clue
    Thanks, The Submit button now works.
    However when i click on Submit it give syntax error:
    Parse error: syntax error, unexpected '@' in /**********/mail.php on line 5
    Got any idea why?

    And how can i configurate the page so it send an email to my adress after someone submit and info. and after pressing Submit pop up window will say "Thanks for submit" and clear the boxes.
     
  11. iPwnJ00

    iPwnJ00 Junior Member

    Joined:
    Mar 10, 2009
    Messages:
    132
    Likes Received:
    21
    Location:
    Melbourne, Australia
    Sorry for the super long delay on reply, I was in the middle of coding something for a client.




    LOL!

    Sorry, I just realised, the code that was posted before was written on a non-English version of Windows, therefore, the quotation marks were not standard. Here is the proper code:

    PHP:
    <?php 

    //enter the address to send the form to 

    $toAddress "someone@somewhere.com"

    //enter the subject of the email you recieve

    $subject "Contact from Web";

    //enter the path to the file where the user gets sent to after submitting the form

    $thankYou "thanks.php"

    $first $_REQUEST['first']; 

    $last $_REQUEST['last'];

    $email $_REQUEST['email'];

    $body 

    First Name: 
    $first

    Last Name: 
    $last

    Email Address: 
    $email"

    mail($toAddress$subject$body"From: $email");

    header("Location: $thankYou");

    ?>

    Also, I see that the 'thank you' page has been put in already.

    See the last line that says 'header..... $thankYou'? That means, after accepting the form and sending an email to you, it will redirect you to whatever '$thankYou' equals.

    A bit above the last line, you see "$thankYou = 'thanks.php'", that's the file that it will redirect you to after the submission.

    You can change that to whatever you want. You don't need a .php file.. You can just have a .html file if you really want.
     
    • Thanks Thanks x 1
  12. Zicky

    Zicky Registered Member

    Joined:
    Mar 7, 2009
    Messages:
    75
    Likes Received:
    14
    Location:
    No Clue
    Thanks Alot!!
    Works perfect.
    Just one last thing, I want after Submitting the info and pressing on "Submit" A box will pop up Says "Thanks for Submit" With "Ok" option which will close the box and stay on same page, and the boxed will clear.
    I dont want to redirect to other thanks.php page.

    Hope you can help em with this one :confused: