1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

PHP coding tables

Discussion in 'Web Development' started by guest, Feb 27, 2008.

  1. guest

    guest New Member

    im trying to input a table where people can sign up for newsletters and emails but im unsure what to put in the name"_" part, or if im doing it right in the first place, when they hit submit, where will it go?

    <div id="left">
    <div id="sign-up">
    <h2>Sign-up for Updates!</h2>
    <form action="" method="get" accept-charset="utf-8">
    <table border="0" cellspacing="2" cellpadding="0">
    <tr><th>Name</th><td><input type="text" name="a" value="" class="text" /></td></tr>
    <tr><th>Email/Phone</th><td><input type="text" name="b" class="text" value="" /></td></tr>
    <tr><th>Full Adress</th><td><input type="text" name="c" value="" class="text" /></td></tr>
    </td></tr>
    <tr><td class="submission" colspan="2"><input type="submit" name="s" value="Submit" /></td></tr>
    </table>
    </form>
    </div>
     
  2. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    First of all this subject is not something that really can be understood in a forum. You will have to Google for some tutorals to understand completely.
    TRY http://www.tizag.com/phpT/fileupload.php
    A basic form is in 3 parts:
    The Form - vistors fill out.
    The Ouput file - that processes the information on the backend of the server.
    The Responce page - That thanks your vistors so they know something happened and that which informs you that some info has been sent, otherwise why have a form.
    The Form - You must make a form defintion. Give it a name. Then a method, this can be post or get. In your case you'll make an html file for your vistors to fill out and send, so you will use post. Finally an action, where to send the info to process, this could go example: to a database or cgi-bin or php file.
    So your code might look like:
    We'll send it to a php file for processing.
    <form name="form1" method="post" action="output.php">
    The form must contain an input such as:
    <tr><td>Name: </td><td><input type="text" size="26" name="name"> required</font></td></tr>
    <tr><td>Email: </td><td><input type="text" size="26" name="email"> required</font></td></tr>
    Now they need a way to submit their data, a button would be nice.
    <input type=submit Value="Submit">
    That's it, a simple form::::
    Of course you need to add some code for your look and feel.
    The Responce Page - thank_you.html May look like this.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Info Sent</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body bgcolor="#D3E378">
    <div align="center">
    <p><font size="4" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF">Thank You</font></strong></font></p>
    <p><font color="#FFFFFF"><strong><font size="4" face="Arial, Helvetica, sans-serif">Your Information Has Been Sent.</font></strong></font></p>
    <p align="center"><font size="2" face="Arial, Helvetica, sans-serif">Press to return <a href="index.html">BACK</font></a></p>
    <font size="1" face="Arial, Helvetica, sans-serif">Powered By: My Super WEB</a></font>
    </div>
    </body>
    </html>
    Now the fun part. Where did you send it?
    To the server where it is to be processed.
    output.php - file
    <?php
    # ----- ENJOY!!!
    # ----------------------------------------------------
    // Receiving variables
    @$name = ($_POST['name']);
    @$email = ($_POST['email']);
    // Validation
    if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
    {
    die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font><br><a href='javascript:history.go(-1);'>Previous Page</a></p>");
    }
    //Sending Email to form owner
    # Email to Owner
    $pfw_header = "From: $email";
    $pfw_subject = "My New Contact Form";
    // CHANGE TO YOUR EMAIL ADDRESS
    $pfw_email_to = "your@emailaddress.com";
    $pfw_message = "Name: $name\n"
    . "email: $email\n"
    @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
    //Sending auto respond Email to user
    # Email to Owner
    $pfw_header = "From: your@emailaddress.com";
    $pfw_subject = "Confirmation - Auto Response";
    $pfw_email_to = "$email";
    $pfw_message = "We have recieved your information and are reviewing it.\n"
    . "Thank You for your interest in our newsletter."
    . "We will get back to you."
    . "\n"
    . "My Great Newsletter Company"
    . "123-456-7890 call anytime"
    . "\n";
    @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
    header("Location: thank_you.html");
    ?>