Welcome to WebDesignForums.net!
You're currently viewing WDF as a guest. By registering for a free account, you'll be able to participate with other members in our friendly community. Being a member allows you to ask questions and get answers for those troublesome web development tasks!

In addition, as a member you'll be able to post your websites up for review. Using our unique website review system you can gain some amazing feedback from some of the best web developers around. This is a completely free service to all registered members.

Ready to register yet? Registration is 100% free. Click Here To Join Now!

Contact Page

Discussion in 'PHP' started by EdMarks, Jun 23, 2012.

  1. Offline

    EdMarks Member

    Message Count:
    51
    Likes Received:
    3
    Trophy Points:
    8
    Gender:
    Male
    Location:
    181º lat 91º long
    Hello Everyone :)

    I am trying to make a contact page and having a hard time.

    Does anyone know a simple tutorial for this, to uses HTML to send an email via PHP or anything else that will work.

    The only thing is I cant have the contact page be a different web page. I simply need to have a form that uses CSS and Javascript for style and some function. But still uses PHP without getting in the way of the others.
    In other words it cant redirect the user once the submit button is clicked.

    Can I just add inline php code and call it a day?
    If so how?

    If you have read this far please check out what I am working on and look at my fail of a contact page.

    SITE I AM WORKING ON

    I could have sworn I had done this in the past. I just followed a tutorial but when I tried to apply it to my this site it resulted in and epic fail. Here is the site I used PHP in the past..

    PAST SITE

    Thanks for all help.


  2. Offline

    Webzarus Well-Known Member

    Message Count:
    3,003
    Likes Received:
    666
    Trophy Points:
    113
    Gender:
    Male
    Might be that the process you're using on this site is not supported by this hosting provider.

    Seriously, some hosting providers require you to use their mail scripts, or they have a certain way you have to send it ( a named smtp server ), for security reasons.

    I've seen some not even allow smtp mail from sites ( usually free hosting accounts )... It that's the case, your code is failing because they have the send mail function turned off...

    Check to see if there are any specifics with your hosting provider... If not then you fist need to setup a test a basic send script to get it working...

    Once you have that, then work on the contact form... To send info to the mail script.

    http://www.w3schools.com/php/php_mail.asp

    That should help with the basic send part of it for testing


  3. Offline

    EdMarks Member

    Message Count:
    51
    Likes Received:
    3
    Trophy Points:
    8
    Gender:
    Male
    Location:
    181º lat 91º long
    Hey Webzarus. Thanks for the response.
    I'ts not the hosting provider cuz I have another page in the same domain that works with the php mailer.
    It doesnt work cuz I don't know what I am doing.

    The main thing I am wondering is if there is a way to use php to mail a form without the webpage being a .php and with the page staying on the same html page the whole time.
    Cuz when I click submit it goes to the php form.

    Can I put inline script while keeping the .html or can the form call a .php script in the backgound without altering the user experience on the .html page?

    The link you sent is what I will need but it doesn't specify about my special specifications.

    :)


  4. Offline

    Webzarus Well-Known Member

    Message Count:
    3,003
    Likes Received:
    666
    Trophy Points:
    113
    Gender:
    Male
    Nope...

    HTML is static ( meaning the server sends the code as formatted)... When you call a php page, it invokes the scripting server side of things and tells it to process and execute the code on the php page.

    Just embedding the php in the HTML will not work..

    Don't know why you are so concerned...

    I guess you could put a redirect to a .html page after the php page processes... Many people send them to a thank you page... ( or whatever you want to call it )...

    If you code and layout is good, and your server response times to good, most people wouldn't even notice as the php page is processed in the background... And then they are sent ( wherever )...


  5. Offline

    SimplyWebsites New Member

    Message Count:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    Location:
    Leicester
    I wrote this for someone else but it should help
    form.html:

    <form method="post" action="submit.php">
    <input type="text" name="firstname" />
    <input type="text" name="email" />
    <input type="text" name="company" />
    <input type="text" name="subject" />
    <textarea name="message" rows="5" cols="30"></textarea>
    <input type="submit" value="Send Message" />
    </form>

    Now that you have you form we need to create submit.php

    submit.php:

    <?
    // The email address you want messages to be sent to
    $your_email_address = "me@example.com";

    // First we need to get all the fields into variables.
    $firstname = $_POST['firstname'];
    $email = $_POST['email'];
    $company = $_POST['company'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];

    // Now lets create the email thats going to be sent to you!
    $subject = "New Contact Form Message";

    $the_email = "You have a new message from: $firstname"."\n\n";
    $the_email .= "Email: $email"."\n";
    $the_email .= "Company: $company"."\n";
    $the_email .= "Subject: $subject"."\n\n";
    $the_email .= "Message: $message"."\n\n";

    // Now lets send the email!
    mail($your_email_address,$subject,$the_email);
    ?>

    At the end of the submit.php you can add one more line to redirect them back to the form
    header('location:form.html');

    make sure you put this before the closing php tag


Share This Page