Permalänk
Medlem

Basic PHP Problem.

Hallå där alla små sweclockare, hoppas ni en trevlig lördag, själv håller jag på med lite basic PHP.
Jag Nginx på en debian server.

Scenario: You are working as IT Support for a small high school in your area. The Parents and Community committee has commissioned a small project to help kids in the school work out exactly how much time they're spending in front of the TV, Computer or Video Game Consoles, as well as collect data on how free time is spent. Creating the form[edit] You've been asked to whip up a prototype form to collect the following info (remember your target audience when labeling your fields!): First and last name Year of birth Current year at school (e.g. 7-12) Number of siblings At what time do they go to bed, and at what time do they wake up. Approximate time spent on homework per day time spent watching TV/DVD etc. per day Time spent using computer or games console per day time spent with family per day time spent with friends per day You do not necessarily need to make your form pretty or worry about Javascript input validation for the prototype, but it certainly needs to be easy to use. Processing your form[edit] Your prototype will also require a php script (or server-side language of your choice) to process the info. The P&C committee have asked for the following: A message saying "Great! Thanks [firstname] for responding to our survey". A display of the students details formatted suitably (just name, birth-year, current school year and number of siblings) An email should be sent to a set email address with a a subject of, for example, "David Terry's Survey results." and a message that includes the data entered (no need to worry about formatting or headers in the email).

Är mitt uppdrag.

Detta är min Kod: var.php

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <html> <head> <style type="text/css"> body { text-align: center; } </style> </head> <body> <body bgcolor="#eae3e3"> <div id="wrap"> <?php $name = $_POST['name']; $surname = $_POST['surname']; $yob = $_POST['yob']; $syskon = $_POST['syskon']; $bedtime = $_POST['bedtime']; $homework = $_POST['homework']; $tv = $_POST['tv']; $game = $_POST['game']; $family = $_POST['family']; $friend = $_POST['friend']; $email = $_POST['email']; ?>

Index.php

<?php include 'var.php'; ?> <html> <h1>Welcome to our survey, please answer <u>ALL</u> the following questions.</h1> <form action="next.php" method="POST"> What is your name?: <input type="text" name="name"><br> What is your surname?: <input type="text" name="surname"><br> What is your year of birth?: <input type="text" name="yob"><br> What is your siblings?: <input type="text" name="syskon"><br> What is your bedtime?: <input type="text" name="bedtime"><br> How much time do you spend with your homework?: <input type="text" name="homework"><br> How much time do you spend with watching TV / Movies?: <input type="text" name="tv"><br> How much time do you spend with computers / playing games?: <input type="text" name="game"><br> How much time do you spend with your family?: <input type="text" name="family"><br> How much time do you spend with your friends?: <input type="text" name="friend"><br> What is your email?: <input type="text" name="email"><br> <input type="submit"> </html>

next.php

<?php include 'var.php'; if(!$name) { echo "You never typed your name"; } elseif(!$surname) { echo "You never typed your surname"; } elseif(!$yob) { echo "You never typed your year of birth"; } elseif(!$syskon) { echo "You never said if you had any siblings"; } elseif(!$bedtime) { echo "You never typed bedtime"; } elseif(!$homework) { echo "You never said how much time you spend on homework / day"; } elseif(!$tv) { echo "You never said how much time you spend on TV / Watching movies / day".; } elseif(!$game) { echo "You never said how much time you spend on the computer / game console"; } elseif(!$family) { echo "You never said how much time you spend with your family / day"; } elseif(!$friend) { echo "You never said how much time you spend with friends / day"; } elseif(!$email) { echo "You never typed you email"; } else { echo "Great! Thanks ".$name." for responding to our survey"; } ?>

Mitt fel är

Serverfel Ett fel uppstod när webbplatsen skulle hämta "url". Den kan ligga nere för underhåll eller vara felkonfigurerad. Här följer några förslag: Läs in webbsidan igen senare. HTTP-fel 500 (Internal Server Error): Ett oväntat tillstånd gjorde att servern inte kunde uppfylla begäran.

Jag får detta erroret i google chrome.

Snälla hjälp mig!

Permalänk
Medlem

Vad exakt vill du ha hjälp med?

Permalänk
Medlem

Haha, ledsen att jag inte skrev, Jag får
"Serverfel
Ett fel uppstod när webbplatsen skulle hämta "url". Den kan ligga nere för underhåll eller vara felkonfigurerad.
Här följer några förslag:
Läs in webbsidan igen senare.
HTTP-fel 500 (Internal Server Error): Ett oväntat tillstånd gjorde att servern inte kunde uppfylla begäran."

Permalänk

prova att ta bort punkten i slutet av din elseif (!$tv){}
skriver från mobilen så det är svårt att få en överblick av koden

Permalänk
Medlem
Skrivet av spot_1337:

prova att ta bort punkten i slutet av din elseif (!$tv){}
skriver från mobilen så det är svårt att få en överblick av koden

Tack, det funkar nu!