realmainer Posted April 3, 2014 Report Posted April 3, 2014 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. Quote
falkencreative Posted April 3, 2014 Report Posted April 3, 2014 I'd suggest watching the "PHP and Javascript Form Validation" series. While it covers building a contact form, rather than a survey form, you'll be using the exact same approach and techniques when building your form. 1 Quote
administrator Posted April 4, 2014 Report Posted April 4, 2014 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 Quote
realmainer Posted April 4, 2014 Author Report Posted April 4, 2014 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 Quote
administrator Posted April 4, 2014 Report Posted April 4, 2014 Did you do the Beginners PHP course yet? Stef Quote
realmainer Posted April 4, 2014 Author Report Posted April 4, 2014 Did you do the Beginners PHP course yet? Stef yes i did And I am going over it again. Quote
geckografix Posted April 4, 2014 Report Posted April 4, 2014 I think going over the course again would be invaluable as I have had 4 courses of the killersites site and have found all of them a great product and easy to follow Quote
realmainer Posted April 4, 2014 Author Report Posted April 4, 2014 I think going over the course again would be invaluable as I have had 4 courses of the killersites site and have found all of them a great product and easy to follow thanks Quote
administrator Posted April 4, 2014 Report Posted April 4, 2014 I think going over the course again would be invaluable as I have had 4 courses of the killersites site and have found all of them a great product and easy to follow Thanks! Stef Quote
administrator Posted April 4, 2014 Report Posted April 4, 2014 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 Quote
realmainer Posted April 24, 2014 Author Report Posted April 24, 2014 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"; ?> Quote
falkencreative Posted April 25, 2014 Report Posted April 25, 2014 What about this code isn't working for you? What are you expecting, and what are you getting? Quote
realmainer Posted April 25, 2014 Author Report Posted April 25, 2014 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> Quote
falkencreative Posted April 25, 2014 Report Posted April 25, 2014 Looks like you are missing the closing "}" on each of your switch statements. Quote
realmainer Posted April 26, 2014 Author Report Posted April 26, 2014 If I put a "}" anywhere on those switch statements I get any error. So I am at a lost as to were you think they need be Quote
falkencreative Posted April 26, 2014 Report Posted April 26, 2014 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. Quote
realmainer Posted April 27, 2014 Author Report Posted April 27, 2014 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."}; Quote
falkencreative Posted April 27, 2014 Report Posted April 27, 2014 Those switch statements need to look like this: switch($_POST['rgroup4']) { case "rg4v1": $value4 = "Radio Group 4 - Value 1 was selected."; break; case "rg4v2": $value4 = "Radio Group 4 - Value 2 was selected."; } Quote
administrator Posted April 28, 2014 Report Posted April 28, 2014 I think going over the course again would be invaluable as I have had 4 courses of the killersites site and have found all of them a great product and easy to follow Thanks for that! Stef Quote
Recommended Posts
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.