Jump to content

Php Form


realmainer

Recommended Posts

I bought complete web programming. I have been watching the videos and need to know what I missed. I am trying to get a survey form to work. My host place tells me I have to have it in php. I have been trying to see what video shows it to me.  Can anyone tell me which one. I have watched all the php ones and did not see it.

 

Link to comment
Share on other sites

When looking at programming, you need to try to figure out what you are really doing at the most basic level.

 

So in this case, you say you have a survey form to create ... all that means, is that you need to create a form and be able to use PHP to capture the information people fill into the form. 

 

It doesn't matter if it is a 'survey' form or a 'contact' form or say a 'fruit and vegetables' form - when it comes down to it, it is all the same.

 

In general, most web programming is:

 

1. Just capturing user inputted information in html forms, cleaning it and inserting it into databases.

2. Then the sending it back to web pages.  

 

This is an oversimplification but nonetheless, it is pretty much it.

 

Stefan

Link to comment
Share on other sites

When looking at programming, you need to try to figure out what you are really doing at the most basic level.

 

So in this case, you say you have a survey form to create ... all that means, is that you need to create a form and be able to use PHP to capture the information people fill into the form. 

 

It doesn't matter if it is a 'survey' form or a 'contact' form or say a 'fruit and vegetables' form - when it comes down to it, it is all the same.

 

In general, most web programming is:

 

1. Just capturing user inputted information in html forms, cleaning it and inserting it into databases.

2. Then the sending it back to web pages.  

 

This is an oversimplification but nonetheless, it is pretty much it.

 

Stefan

Yes it sound simple. But my server told me I need it to be a php. That is were I am ost. As I can not figure out how to get the php to work with the form

Link to comment
Share on other sites

Be sure that you are actually writing out the code as you watch the videos ... this is key if you want to really understand and internalize the information.

 

I've gone the route in the past (1995-96) where I would just read and take notes and I became a master of JavaScript - or so I thought. I could answer any question but when it came to actually writing code, I sucked.

 

... You have to write the code.

 

Stef

Link to comment
Share on other sites

  • 3 weeks later...

I have been working to figure this out. Here are the 2 pages I have The form and PHP page but I can not get it too work can someone tell me what I did wrong?

 <form  method="post"  name="form1" id="form1" action="survey.php">
      <p>
        <label>First Name
          <input type="text" name="fname" id="fname" />
        </label>
     </p>
      <p>
        <label>Last Name
          <input type="text" name="lname" id="lname" />
        </label>
      </p>
      <p>
        <label>Email
          <input type="text" name="email" id="email" />
        </label>
      </p>
       <p>
        <label>What state you from?
          <input type="text" name="state" id="state" />
        </label>
      </p>
      <p>
        <label> Would you like to see a nation wide pool? Winner by antler size.<br />
     <input type="radio" name="rgroup1" value="rg1v1"> yes
   <input type="radio" name="rgroup1" value="rg1v2"> no
      </label> 
      </p>
      <p>
        <label> Would you like to see a Maine State wide pool? Winner by weight.<br />
         <input type="radio" name="rgroup2" value="rg2v1"> yest
   <input type="radio" name="rgroup2" value="rg2v2"> no
   </label>
      </p>
      <p>
        <label> Would you like to see a Sanford Maine local pool? Winner by weight. All deer would be put on the same scale in Sanford. <br />
         <input type="radio" name="rgroup3" value="excellent"> yes
   <input type="radio" name="rgroup3" value="good"> no
   </label>
      </p>
      <p>
        <label> Would you be willing to pay $10.00 for the Nation wide pool? <br />
         <input type="radio" name="rgroup4" value="excellent"> yes
   <input type="radio" name="rgroup4" value="good"> no
          </label>
        <br />
      </p>
      <p>
        <label>Comments <br />
          <textarea name="comments" id="comments" cols="45" rows="5"></textarea>
        </label>
      </p>
      <p>
        <input name="submit" type="submit" class="buttons" id="submit" value="Send" />
      </p>
    </form>
 
Now the PHP page
 
<?php
 
/* Email Variables */
 
$emailSubject = 'survey!';
$webMaster = 'realmainer@gmail.com';
 
 
/* Data Variables */
 
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$comments = $_POST['comments'];
 
 
 
$body = <<<EOD
<br><hr><br>
Name: $fname <br>
Name: $lname <br>
Email: $email <br>
Comments: $comments <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);
 
 
/* Results rendered as HTML */
 
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="2;URL=http://www.whitetaildeerpool.com/.html">
 
 
-->
</style>
</head>
<div align="center">thank you for filling out our form !</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>
Link to comment
Share on other sites

I get this Parse error: syntax error, unexpected $end in /home/realmai1/public_html/whitetaildeerpool.com/survey.php on line 87

 

There is nothing on line 87 but on line 68 is a red mark see photo

 

Here is the code again 

<?php

 
/* Email Variables */
 
$emailSubject = 'survey!';
$webMaster = 'realmainer@gmail.com';
 
 
/* Data Variables */
 
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$state = $_POST['state'];
 
switch($_POST['rgroup1']) {
    case "rg1v1":
        $value = "Radio Group 1 - Value 1 was selected.";
        break;
    case "rg1v2":
        $value = "Radio Group 1 - Value 2 was selected.";
 
switch($_POST['rgroup2']) {
    case "rg2v1":
        $value2 = "Radio Group 2 - Value 1 was selected.";
        break;
    case "rg2v2":
        $value2 = "Radio Group 2 - Value 2 was selected.";
 
switch($_POST['rgroup3']) {
    case "rg3v1":
        $value3 = "Radio Group 3 - Value 1 was selected.";
        break;
    case "rg3v2":
        $value3 = "Radio Group 3 - Value 2 was selected.";
 
switch($_POST['rgroup4']) {
    case "rg4v1":
        $value4 = "Radio Group 4 - Value 1 was selected.";
        break;
    case "rg4v2":
        $value4 = "Radio Group 4 - Value 2 was selected.";
 
 
$comments = $_POST['comments'];
 
echo $value;
echo $value2;
echo $value3;
echo $value4;
 
$body = <<<EOD
<br><hr><br>
Name: $fname <br>
Name: $lname <br>
Email: $email <br>
State: $state <br />
 
comments: $comments <br>
 
Comments: $comments <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);
?>
 
/* Results rendered as HTML */
 
 
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="2;URL=http://www.whitetaildeerpool.com">
 
 
-->
</style>
</head>
<div align="center">thank you for filling out our form !</div>
</div>
</body>
</html>
 

post-130505-0-96848300-1398424521_thumb.jpg

Link to comment
Share on other sites

These are your switch statements:

switch($_POST['rgroup4']) {
    case "rg4v1":
        $value4 = "Radio Group 4 - Value 1 was selected.";
        break;
    case "rg4v2":
        $value4 = "Radio Group 4 - Value 2 was selected.";
Note the opening "{", but no closing "}"? You need a closing } at the end of each of your four switch statements.
Link to comment
Share on other sites

okay here are 2 of the 4 switches I put the closing } and I get the error on each line I put that closing } There has to be another reason why.

 

switch($_POST['rgroup3']) {
    case "rg3v1":
        $value3 = "Radio Group 3 - Value 1 was selected.";
        break;
    case "rg3v2":
        $value3 = "Radio Group 3 - Value 2 was selected."};
 
switch($_POST['rgroup4']) {
    case "rg4v1":
        $value4 = "Radio Group 4 - Value 1 was selected.";
        break;
    case "rg4v2":
        $value4 = "Radio Group 4 - Value 2 was selected."};
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...