Advertisement
Guest User

phpproblem

a guest
Jun 23rd, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1. <!Doctype html>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8"><!--characters recognised-->
  5.   <title>Register</title>
  6. <style>
  7.  
  8. body{
  9.   background-image: url(my_images//background_homepage.jpg);
  10.   background-repeat: no-repeat;
  11.   background-size:cover;
  12. }
  13. </style>
  14. </head>
  15. <body>
  16.  
  17. <?php
  18.   extract( $_POST );//superglobal variable
  19.  
  20. if( isset($_POST['submit'] ) ) {
  21.  
  22.   print_r($_POST);
  23.  
  24.   //Getting the variables from 'registerForm' ++  /* checking if user inputs are set */
  25.   $first_name = (isset($_POST['onoma'])) ? $_POST['onoma'] : NULL;
  26.   $last_name = (isset($_POST['epwnumo'])) ? $_POST['epwnumo'] : NULL;
  27.   $age = (isset($_POST['hlikia'])) ? $_POST['hlikia'] : NULL;
  28.   $job = (isset($_POST['epaggelma'])) ? $_POST['epaggelma'] :NULL;
  29.   $email = (isset($_POST['mail'])) ? $_POST['mail'] : NULL;
  30.   $username = (isset($_POST['username'])) ? $_POST['username'] : NULL;
  31.   $password = (isset($_POST['password'])) ? $_POST['password'] : NULL;
  32.  
  33. //INSERT INTO Query Creation
  34. $sqlQuery = "INSERT INTO registered_user ( age,email,fname,job,lname,password,username )
  35.  VALUES ('$age','$email','$first_name','$job','$last_name','$password','$username')";
  36.  
  37. //MySQL connection
  38. if( !( $database = mysql_connect( "localhost","root","" ) ) )//server name , a username , password
  39.   die( "Αποτυχημένη σύνδεση στη βάση δεδομένων </body></html>" );//if false --> script gets terminated
  40.  
  41. //Opening database "htmlproject"
  42. if( !mysql_select_db("htmlproject",$database) )//Database to be used , htmlproject
  43.   die( "Αποτυχημένο άνοιγμα της htmlproject βάσης δεδομένων </body></html>" );
  44.  
  45. //Query
  46. mysql_query( $sqlQuery, $database);
  47. if( !( $result = mysql_query( $sqlQuery, $database) ) )
  48. {
  49.   print( "Αποτυχημένο προσπάθεια υποβολής ερωτήματος! <br />" );
  50.   die( mysql_error() . "</body></html>" );
  51. }else{
  52.   print("Επιτυχής υποβολή ερωτήματος!");
  53. }//end if
  54.  
  55. //Free resources
  56. mysql_close( $database );
  57.  
  58. }//end ifisset
  59. ?><!--end php script.To be executed by server-->
  60.  
  61. <script type="text/javascript">//H εγγραφή ολοκληρώθηκε  επιστροφή στην αρχική σελίδα
  62. var r=window.confirm("H εγγραφή ολοκληρώθηκε");
  63. if( r == true){
  64.   document.location.href = "SELIDA1.html";
  65. }else{
  66.     document.location.href = "SELIDA1.html";
  67. }
  68. </script>
  69.  
  70. </body>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement