Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Website form Html/PHP help

    Hey
    I am trying to get a website contact form to email me content that people submit. I have very basic knowledge of coding.

    I have read through instructions on several websites for how to set up a form using php script and html. Many of those sites gave sample codes to use. I have tried countless variations of php and html code. I have tested them again and again without any success. Does anyone know what the problem is?

    This is the html code for the form:
    <div class="grid_8">
    <div class="left-1">
    <h2>Contact Form</h2>
    <form id="form" method="post" action="contact.php" >
    <form action="contact.php" method="post" id="ContactForm">
    <fieldset>
    <label><strong>Name:</strong><input type="text" value=""></label>
    <label><strong>Email:</strong><input type="text" value=""></label>
    <label><strong>Phone:</strong><input type="text" value=""></label>
    <label><strong>Message:</strong><textarea></textarea></label>

    <div class="btns"><a href="#" class="button">Clear</a><a href="contactsthankyou.html" class="button" onClick="document.getElementById('form').submit()">Send</a></div>
    </fieldset>
    </form>
    </div>
    </div>

    This is one of the php codes that I found, I just added the sections in the form and changed the email address:

    <?php
    $to = "umar.zulqarnain@gmail.com";
    $subject = "Contact Form";
    $name = $_REQUEST['name'] ;
    $email = $_REQUEST['email'] ;
    $phone = $_REQUEST['phone'] ;
    $message = $_REQUEST['message'] ;
    $headers = "From: $email";
    $sent = mail($to, $subject, $message, $headers) ;
    if($sent)
    {print "Your mail was sent successfully"; }
    else
    {print "We encountered an error sending your mail"; }
    ?>

  • #2
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    375
    Thanks
    9
    Thanked 55 Times in 54 Posts
    Helo Umar.

    To start,
    each of those HTML input elements need names. Also, you don't need javascript to reset nor to send form.

    A standard HTML form might look like the following (see the red texts):
    Code:
    <form action="contact.php" method="post" id="ContactForm">
    	<fieldset>
    		<label><strong>Name:</strong><input type="text" name="name" value=""/></label>
    		<label><strong>Email:</strong><input type="text" name="email" value=""/></label>
    		<label><strong>Phone:</strong><input type="text" name="phone" value=""/></label>
    		<label><strong>Message:</strong><textarea name="message"></textarea></label>
    		<div class="btns">
    			<input type="reset" value="Clear"/>
    			<input type="submit" value="Send"/>
    		</div>
    	</fieldset>
    </form>
    After that, try ask PHP guys for better PHP codes. Do some search there first

    Good luck!

  • #3
    New to the CF scene
    Join Date
    Jan 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by hdewantara View Post
    Helo Umar.

    To start,
    each of those HTML input elements need names. Also, you don't need javascript to reset nor to send form.

    A standard HTML form might look like the following (see the red texts):
    Code:
    <form action="contact.php" method="post" id="ContactForm">
    	<fieldset>
    		<label><strong>Name:</strong><input type="text" name="name" value=""/></label>
    		<label><strong>Email:</strong><input type="text" name="email" value=""/></label>
    		<label><strong>Phone:</strong><input type="text" name="phone" value=""/></label>
    		<label><strong>Message:</strong><textarea name="message"></textarea></label>
    		<div class="btns">
    			<input type="reset" value="Clear"/>
    			<input type="submit" value="Send"/>
    		</div>
    	</fieldset>
    </form>
    After that, try ask PHP guys for better PHP codes. Do some search there first

    Good luck!
    Thank you! I've been reading countless sources and asking around for help. Someone was able to fix the php coding and I do receive an email with the form submission now.

    The only issue is that it only works when, like you said, html is used for form submission and not javascript.
    This is the original form submission code:
    <div class="btns"><a href="#" class="button">Clear</a><a href="contactsthankyou.html" class="button" onClick="document.getElementById('form').submit()">Send</a></div>

    This is the form submission code that sends me an email:
    <input type="reset" value="Clear"/>
    <input type="submit" value="Send"/>

    The issue is that the second set of code gets rid of all the formatting. I want the buttons to be consistent with the buttons on the rest fo the website. I've been playing around but nothing works. know how to solve the problem?

  • #4
    New to the CF scene
    Join Date
    Jan 2014
    Location
    Dubai, UAE
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <a href="http://www.phpform.info">HTML/PHP form generator</a> the quickest, easiest way to create HTML/PHP forms

    HTML/PHP Form Generator makes the creation of forms a breeze. By clicking on the form controls with this website it is possible to create the code for a HTML.
    Last edited by vinyl-junkie; 01-30-2014 at 01:19 PM. Reason: signatures only allowed through the control panel


  •  

    Posting Permissions

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