2016-08-09 7 views
1

Ich habe ein Formular auf einer Website. Ich muss meine Informationen in der Datenbank speichern. Ich habe eine Datenbank in localhost gemacht, aber wenn ich auf submit klicke, wird der gesamte Code von register.php auf der gleichen Seite angezeigt und keine Daten in der Datenbank gespeichert, ich habe alle Dateien in htdocs platziert. Ich habe Formular in index.html und register.php Datei ist getrennt. Hier ist die PHP-Datei:Meine Daten werden nicht per PHP an die Datenbank gesendet

<?php 
    mysql_connect('localhost','root',''); 
    if(!$link){ 
     die('could not connect: ' . mysql_error()); 
    } 
    echo 'connected successfully'; 
    mysql_select_db(learnqurandb); 

     $name = $_post['fullname']; 
     $email = $_post['email']; 
     $mobile = $_post['mobile']; 
     $country = $_post['country']; 
     $course = $_post['course']; 
     $skype_id = $_post['skype']; 

    if($name == ""){ 
     echo "<script>alert('please enter your name')</script>"; 
     exit(); 
    } 
    if($email == ""){ 
     echo "<script>alert('please enter your E-mail')</script>"; 
     exit(); 
    } 
    if($mobile == ""){ 
     echo "<script>alert('please enter your Mobile Numbet')</script>"; 
     exit(); 
    } 
    if($country == ""){ 
     echo "<script>alert('please enter your country name')</script>"; 
     exit(); 
    } 
    if($course == ""){ 
     echo "<script>alert('please select your desire course')</script>"; 
     exit(); 
    } 
    if($skype_id == ""){ 
     echo "<script>alert('please enter your Skype ID')</script>"; 
     exit(); 
    } 

    $check_skype_id = "select * from learnquran where skype = '$skype_id"; 
    $count = mysql_query('$check_skype_id'); 

    if(mysql_num_rows ($count) > 0){ 

     echo"<script>alert('Skype_id $skype_id is already exists, please try another one.')</script>"; 
     exit(); 
    } 

    $query = "INSERT INTO registration (fullname,email,mobile,country,course,skype) values('$name','$email','$mobile','$country','$course','$skype_id')"; 

    if(mysql_query ($query)){ 

     echo "<script>alert('Registration Successfull')</script>"; 
    } 
} 
?> 

meine HTML-Formular ist diese

<div id="form_div"> 
     <h2>Quick Registration</h2> 
     <form name="Form1" method="post" action="register.php" /> 
     <label for="name">Name:</label> 
     <input type="text" name="fullname" id="fname" /><br><br> 
     <label for="email">Email:</label> 
     <input type="text" name="email" id="user_email" /><br><br> 
     <label for="mobile">Mobile:</label> 
     <input type="text" name="mobile" id="user_mobile" /><br><br> 
     <label for="country">Country:</label> 
     <input type="text" name="country" id="user_country" /><br><br> 
     <label for="skype">Skype ID:</label> 
     <input type="text" name="skype" id="skype_id" /><br><br> 
     <label for="course">Course:</label> 
     <select name="course" id="desired_course" ><br><br> 
     <option value="Select course..." selected>Select course</option><br> 
     <option value="Quran Reading">Quran Reading</option> 
     <option value="Memorizing the Holy Quran">Memorizing Holy  Quran</option> 
     </select><br><br> 
     <input type="submit" class="submit" id="button1" value=""/> 
     </form> 
    </div> 
+1

'" Es zeigt den gesamten Code von register.php auf der gleichen Seite an "' - Wenn Sie PHP-Code in Ihrem Browser sehen, dann wird PHP auf Ihrem Server überhaupt nicht ausgeführt. Entweder ist PHP nicht installiert oder es ist nicht korrekt konfiguriert. – David

+0

'mysql_query ('$ check_skype_id')' nicht arbeiten, verwenden '' 'anstelle von' '', lieber lassen sie complety – JOUM

+0

Ihre '$ check_skype_id' Abfrage benötigen eine Schließung' '' am Ende – JOUM

Antwort

Verwandte Themen