Jump to content

Recommended Posts

Hi guys I'm new to this. I tried to post this yesterday,thought it posted but don't see it today. this is my problem: This is my first try at php.I have a contact form with: First Name, Last Name, Email, Comments, a checkbox for newsletter, and a couple of buttons to reset and to submit. It works but does not send the the comment section or the or the check box. Being my first time working with php I'm stuck, and the band is really needing me to get this done. Any help would be greatly appreciated! Thank you! I did this with dreamweaver.

 Thanks again!

 

Code Below:

 

 
<!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>Comments</title>
<style type="text/css">
<!--
body,td,th {
    color: #FFFFFF;
}
body {
    background-color: #000000;
    background-image: url(/mcfunkband/public_html/images/aa_stars.jpg);
}
-->
</style></head>
 
<body>
 
<?php
 
 
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$newsletter = $_POST['newsletter'];
 
//Sending Email to form owner
$header = "From: $email\n"
. "Reply-To: $email\n";
$subject = "Submission From My Form";
$email_to = "***@****.com";
$message = "name: $fname . $lname\n"
. "email: $email\n";
mail($email_to, $subject ,$message ,$header ) ;
 
?>
 

_______________________________________________________________________________________________

 

 

html:

_______________________________________________________________________________________________

 

 
<form id="form1" name="form1" method="post" action="result.php">
    <table width="100%" border="5">
          <tr>
            <td><div align="right">
              <label for="fname">First Name:</label>
            </div></td>
            <td><div align="left">
              <input type="text" name="fname" id="fname" />
            </div></td>
          </tr>
          <tr>
            <td><div align="right">
              <label for="lname">Last Name:</label>
            </div></td>
            <td><div align="left">
              <input name="lname" type="text" id="lname" maxlength="25" />
            </div></td>
          </tr>
          <tr>
            <td><div align="right">
              <label for="email">Emai:l</label>
            </div></td>
            <td><div align="left">
              <input type="text" name="email" id="email" />
            </div></td>
          </tr>
          <tr>
            <td><div align="right"></div></td>
            <td><div align="left"></div></td>
          </tr>
          <tr>
Link to comment
https://forums.phpfreaks.com/topic/279098-hi-i-need-help-on-a-php-form/
Share on other sites

Get rid of all those divs!!!  Needless.

 

Plus your initial post shows only 3 input fields - where are the rest.

 

The interface between html and php is the vars identified by the "name=" attributes of input tags.  Plus handling checkboxes is tricky for newcomers so you should google something like "php handling checkboxes" and look for a good example.  Plenty of them out there.

I would be careful with rushing the form. In addition to it not working, the script which sends out the e-mail could be used for e-mail injections. Note that there are many articles online for more information:

https://www.google.com/search?q=php+injection+email

 

 

As for getting something online soon, have you considered using a third-party solution? Google forms, for example, are free and can be embedded within existing websites.

https://support.google.com/drive/answer/87809?hl=en

 

The customization options are a little to be desired, but it's something to consider while you figure out an alternative.

Hello Mytdred,

 

You don't put any submit field on your form. That is why you are not getting the values I believe. Add the below code at the end of your form. Also add the comment field and other needed fields to your form.


<input type="submit" name="submit" value="submit"> 

Regards,

 

Krishnadas  :rolleyes:

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.