Results 1 to 2 of 2

Thread: Form

  1. #1
    Join Date
    Jul 2006
    Posts
    89

    Form

    Hi All,

    Im just trying to do an Application Form on a site im doing, but need help!

    Please could anyone help with the following -

    Have the Application Form - submit into mysql database,
    does javascript need to be used for the submit button also?

    Have the Form - sent to an email address

    Have Form - validation

    Below is my form -

    HTML Code:
    <br><b>Section 1</b>
                                   <br>Details of person/people for whom help is being    sought.<br>
                        </td>
                      </tr>   
    
                  <form action="insert.php" method="post">
    
     <tr>
                 <td>Name:</td>
          <td><input name="name" type="text" size="100">
                  <br></td>
           </tr>
     <tr>
                 <td>Date of Birth: </td>
                 <td><input type="text" name="dob"><br></td>
           </tr>
            <tr>
                 <td>Address 1:</td>
                 <td><input type="text" name="a1"><br></td>
           </tr>
            <tr>
                 <td>Address 2:</td> 
          <td><input type="text" name="a2"><br></td>
           </tr>
            <tr>
                 <td>Postcode:</td> 
                 <td><input type="text" name="psc"><br></td>
           </tr>
            <tr>
                 <td>Town/City:</td> 
                 <td><input type="text" name="tc"><br></td>
           </tr>
            <tr>
                 <td>Phone: </td>
                 <td><input type="text" name="phone"><br></td>
           </tr>
            <tr>
                 <td>Email:</td> 
                 <td><input type="text" name="email"><br></td>
           </tr>
            <tr>
                 <td>Type of request:</td>
                 <td><select name='typerequest'>
              <option selected>Please Select
              <option>Equipment for home
              <option>Medical
              <option>Transport
                    </select><br></td>
           </tr>
            <tr>
                 <td>Amount of grant required:</td>
                 <td><select name='grant'>
              <option selected>Please Select
              <option>Up to - £1000
              <option>Up to - £3000
              <option>Up to - £5000
                   </select><br></td>
           </tr>
            <tr>
                <td>Brief outline of request:</td>
                <td><textarea name="outlinerequest"></textarea><br></td>
           </tr>
            <tr>
                <td>Details of request:</td> 
                <td><textarea name="detailsrequest"></textarea><br></td>
           </tr>
              </table>
            <tr>     
    
                <td><br><b>Section 2</b><br>Relationship to person/people above 
                    <select name='relate'>
             <option selected>Please Select
             <option>Parent
             <option>Friend
             <option>Therapist
                    <option>Representative of institution
                    <option>Other
                  </select><br></td>
           </tr> 
            <tr>
             <table width="100%" height="270" border="0">
             <tr>
                <td><br>Name:</td>
                <td><input type="text" name="name2"><br></td>
           </tr>
            <tr>
                <td>Address 1:</td>
                <td><input type="text" name="a12"><br></td>
           </tr>
            <tr>
                <td>Address 2:</td>
                <td><input type="text" name="a22"><br></td>
           </tr> 
            <tr>
                <td>Postcode:</td>
                <td><input type="text" name="psc2"><br></td>
           </tr>
            <tr>
                <td>Town/City:</td>
                <td><input type="text" name="tc2"><br></td>
           </tr>
            <tr>
                <td>Phone:</td>
                <td><input type="text" name="phone2"><br></td>
           </tr>
            <tr>
                <td>Email:</td> 
                <td><input type="text" name="email2"><br></td>
           </tr>   
     <tr>
             
            </form>
    
           <tr>
               <td>Submit</td>
           </tr>
           <tr>
         <td>
    If you have any questions regarding this form or it does not meet your needs, please 
    feel free to email <a href='mailto:brenda.yong@sfcharity.co.uk'>Brenda Yong</a>
    
             </td>
           </tr>

    Php code so far -

    <?php
    $user="c";
    $password="c";
    $database="charity";

    mysql_connect("localhost",$user,$password);
    if(!mysql_select_db($database) )
    echo mysql_error();


    $query = "INSERT INTO contacts VALUES

    mysql_query($query);
    mysql_close();
    echo "ok";
    ?>

    Please can anyone help??

    Thanks

  2. #2
    Join Date
    May 2006
    Posts
    275
    This may not be what you're looking for, but thanks to Pilot Designs I found a fantastic PHP script to send form results to an email address. It's so easy even a gnubler can do it.

    Here's the URL: http://www.scriptsearch.com/cgi-bin/jump.cgi?ID=1449

    Here's the PHP code:
    Code:
    <?php
    
    //--------------------------Set these parameters--------------------------
    
    
    $subject = 'Form Submission';                // Subject of email sent to you.
    $emailadd = 'youremail@anywhere.com';        // Your email address. This is where the form information will be sent.
    $url = 'http://www.mydomain.com/whatever/';               // Where to redirect after form is processed.
    $req = '1';                                  // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
    
    // --------------------------Do not edit below this line--------------------------
    $text = "Results from form:\n\n";       
    $space = '  ';
    $line = '
    ';
    foreach ($_POST as $key => $value)
    {
    	if ($req == '1')
    	{
    		if ($value == '')
    		{echo "$key is empty";die;}
    	}
    	$j = strlen($key);
    		if ($j >= 20)
    		{echo "Name of form element $key cannot be longer than 20 characters";die;}
    	$j = 20 - $j;
    		for ($i = 1; $i <= $j; $i++)
    		{$space .= ' ';}
    	$value = str_replace('\n', "$line", $value);
    	$conc = "{$key}:$space{$value}$line";
    	$text .= $conc;
    	$space = '  ';
    }
    mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
    ?>
    And here's the code to put at the beginning of your form in your HTML document:
    Code:
    <form action="nameofformscript.php" method="post" class="cssform">

Similar Threads

  1. passing information from 1 form to another
    By amanxman in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 11 Apr 2006, 03:44 AM
  2. Insert a form within a form
    By stevenbhn in forum General Questions
    Replies: 1
    Last Post: 10 Feb 2006, 05:16 PM

Posting Permissions

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