Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //begin php script
- $compemail=$_POST[email];
- $compcemail=$_POST[cemail];
- if ($compemail === $compcemail)//compare email inputs to check they match
- {
- if (preg_match("/^.+@.+\..+/",$compemail))//compare email to a pattern ANY-@-ANY-.-
- {
- //sql login info
- $host="localhost";
- $user="college";
- $password="1981great";
- $dbname="college";
- $con = mysql_connect($host,$user,$password);//connect to database if FAIL display error
- if (!$con)
- {
- die('Could not connect this could mean parts of the server are offline PLEASE contact the administrator');
- }
- mysql_select_db($dbname, $con);//open database
- //insert data
- $sql="INSERT INTO teachin1 (fname,lname,email,Cv1,Cv2,Cv3,Cv4,Cv5,Cv6,Cv7,Cv8,Cv9)
- VALUES
- ('$_POST[fname]','$_POST[lname]','$_POST[email]','$_POST[Cv1]','$_POST[Cv2]','$_POST[Cv3]','$_POST[Cv4]','$_POST[Cv5]','$_POST[Cv6]','$_POST[Cv7]','$_POST[Cv8]','$_POST[Cv9]') ";
- if (!mysql_query($sql,$con))//if query failed display error else execute finishing code
- {
- die('Error please contact the administrator quoting: ' . mysql_error());
- }
- else
- {
- echo "<p>Thanks <strong>$_POST[fname], $_POST[lname]</strong><br/>your choice has been saved</p>an email has been sent to <strong>$_POST[email]</strong> detailing your choices";
- echo "<br/><a href='index.html'>GO BACK</a>";
- //$to=$_POST[email];
- //$headers = "From: admin@armouredcrow.org";
- //$subject=$_POST[fname]+", course submission";
- //$body="Thank you $_POST[fname] $_POST[lname] your submission is compleate";
- //mail($to,$subject,$body,$headers);
- }
- mysql_close($con);//close sql connection
- }
- else
- {
- echo "<p>Invalid email adress please go back and try again</p><br/>";//if email dosnt match pattern dump previous display error
- }
- }
- else
- {
- echo "<p>Sorry your email adresses didnt match please go back and try again</p><br/>";//if emails dont match display error
- }
- //end php script
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement