Unable to insert data in Mysql.

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Unable to insert data in Mysql.

    Hello to you all,

    I'm a complete newbie using PHP and Mysql. On my search for a member log-in script I read a lot about it, and came here across a login script original from PHP HTML MySQL ASP articles tutorials, free scripts and programming forum I tried to modify this script according to my needs. I am able to connect to Mysql and the database, there are no errors. The log-in page is popping up, then I am able to go to the subscribe page with the form. But trying to subscribe I get a blank page. Hopefully somebody can put me on the right track.

    Sign-up script:

    PHP Code:
    </html><!DOCTYPE htmll PUBLIC "-//W3C//DTD XhtmlL 1.0 Strict//EN" "http://www.w3.org/TR/xhtmll1/DTD/xhtmll1-strict.dtd">
    <htmll xmlns="http://www.w3.org/1999/xhtmll" xml:lang="en" lang="en">
    <?
    include "include/z_db.php";// database connection details stored here

    ?>

    <html>

    <head>
      <meta http-equiv="content-type" content="text/htmll; charset=utf-8" />
      <meta name="description" content="Your description goes here" />
      <meta name="keywords" content="your,keywords,goes,here" />
      <meta name="author" content="Your Name" />
      <link rel="stylesheet" type="text/css" href="cecilia.css" media="screen,projection" />
      <title>Inlog formulier</title>


    </head>

    <body>
    <div id="wrap">
        <div id="header" style="width: 760px; height: 250px">
            <h1><font color="#FFFFFF">Fanfare St. Cecilia Handel</font></h1>
        </div>

        <div id="leftside">
            <ul class="avmenu">
                <li><a href="http://coding-talk.com/f14/index.html">Startpagina</a></li>
                <li><a href="http://coding-talk.com/f14/fanfare.html">De Fanfare</a>
                
                <li><a href="http://coding-talk.com/f14/opleiding.html">Opleiding</a></li>
                <li><a href="http://coding-talk.com/f14/vrienden.html">De Vrienden</a></li>
                <li><a href="http://coding-talk.com/f14/musicool.html">Musicool</a></li>
                <li><a href="http://coding-talk.com/f14/fotos.html">Foto's</a></li>
                <li><a class="current" href="http://coding-talk.com/f14/login.php">Leden login</a>
                <li><a href="http://coding-talk.com/f14/contact.html">Contact</a></li>
            </ul>
        </div>
        
        <div id="extras">
            <div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<images  src="../images/logo.jpg" height="13%" width="52%" alt="logo"><br><br></div>
            <h2 align="center"><b>Agenda</b></h2></font><br>
            <ul>
                <li><b>6 November</b></br>
                    Uitwisselingsconcert met fanfare Juliana uit Haps</li><br>
                <li><b>20 November</b><br>
                    Intocht Sinterklaas</li><br>
                <li><b>18 December</b><br>
                    Kerstconcert</li>
                <li><b>25 December</b><br>
                    Opluistering eucharistieviering</li>
            </ul>
            <p align="center">voor details zie <a href="http://coding-talk.com/f14/jaarprogramma.html">jaarprogramma </a></p>
        </div>

    <script type="text/javascript"> 
    function validate(form) { 
    if (!document.form1.agree.checked) { alert("Heeft u gecontroleerd of het formulier correct is ingevuld."); 
     return false; } 
    return true;
    }
    </script>

       <div id="content">
        <center><body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
       
        <table border='0' width='50%' cellspacing='0' cellpadding='0' align=center><form name=form1 method=post action=signupck.php onsubmit='return validate(this)'><input type=hidden name=todo value=post>

        <tr bgcolor='#f1f1f1'>
        <td align=center colspan=2><font face='Verdana' size='2' ><b>Inschrijfformulier</b></td></tr>
        <tr ><td >&nbsp;<font face='Verdana' size='2' >Gebruikersnaam</td><td ><font face='Verdana' size='2'><input type=text name=Gebruikersnaam></td></tr>
        
        <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >Wachtwoord</td><td ><font face='Verdana' size='2'><input type=text name=Wachtwoord></td></tr>
        <tr ><td >&nbsp;<font face='Verdana' size='2' >Herhaal wachtwoord</td><td ><font face='Verdana' size='2'><input type=text name=Wachtwoord2></td></tr>


        <tr bgcolor='#f1f1f1'><td ><font face='Verdana' size='2' >&nbsp;Achternaam</td><td  ><input type=text name=Achternaam></td></tr>
        <tr ><td >&nbsp;<font face='Verdana' size='2' >Voorvoegsel</td><td ><font face='Verdana' size='2'><input type=text name=Voorvoegsel></td></tr>

        <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >Voornaam</td><td ><font face='Verdana' size='2'><input type=text name=Voornaam></td></tr>
        <tr ><td >&nbsp;<font face='Verdana' size='2' >Geboortedatum</td><td ><font face='Verdana' size='2'><input type=text name=Geboortedatum></td></tr>
        
        <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >E-mailadres</td><td ><font face='Verdana' size='2'><input type=text name=Emailadres></td></tr>
        <tr ><td >&nbsp;<font face='Verdana' size='2' >Adres</td><td ><font face='Verdana' size='2'><input type=text name=Adres></td></tr>
        
        <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >Postcode</td><td ><font face='Verdana' size='2'><input type=text name=Postcode></td></tr>
        <tr ><td >&nbsp;<font face='Verdana' size='2' >Plaats</td><td ><font face='Verdana' size='2'><input type=text name=Plaats></td></tr>
        
        <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >Telefoon</td><td ><font face='Verdana' size='2'><input type=text name=Telefoon></td></tr>
        <tr ><td >&nbsp;<font face='Verdana' size='2' >Mobiel</td><td ><font face='Verdana' size='2'><input type=text name=Mobiel></td></tr>
        
        <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >Instrument</td><td ><font face='Verdana' size='2'><input type=text name=Instrument></td></tr>
        
        <tr ><td >&nbsp;<font face='Verdana' size='2' >Het formulier is correct ingevuld</td><td ><font face='Verdana' size='2'><input type=checkbox name=agree value='yes'></td></tr>

        <tr><td align=center colspan=2><input type=submit value=Inschrijven></td></tr>
        </table>


        <?
        require "bottom.php";
        ?></center>

       </div>


        <div id="footer">
            <p><span>&copy; 2011 Fanfare St. Cecilia</a></span><br /></p>
        </div>

    </div>
    </body>
    </html>
    Sign-up check script:

    PHP Code:
    <?
    include "include/z_db.php";// database connection details stored here
    // Collect the data from post method of form submission // 
    $Gebruikersnaam=$_POST['Gebruikersnaam'];
    $Wachtwoord=$_POST['Wachtwoord'];
    $Wachtwoord2=$_POST['Wachtwoord2'];
    $agree=$_POST['agree'];
    $todo=$_POST['todo'];
    $Achternaam=$_POST['Achternaam'];
    $Voorvoegsel=$_POST['Voorvoegsel'];
    $Voornaam=$_POST['Voornaam'];
    $Geboortedatum=$_POST['Geboortedatum'];
    $E-mailadres=$_POST['E-mailadres'];
    $Adres=$_POST['Adres'];
    $Postcode=$_POST['Postcode'];
    $Plaats=$_POST['Plaats'];
    $Telefoon=$_POST['Telefoon'];
    $Mobiel=$_POST['Mobiel'];
    $Instrument=$_POST['Instrument'];

    ?>

    </html><!DOCTYPE htmll PUBLIC "-//W3C//DTD XhtmlL 1.0 Strict//EN" "http://www.w3.org/TR/xhtmll1/DTD/xhtmll1-strict.dtd">
    <htmll xmlns="http://www.w3.org/1999/xhtmll" xml:lang="en" lang="en">
      
    <html>

    <head>
      <meta http-equiv="content-type" content="text/htmll; charset=utf-8" />
      <meta name="description" content="Your description goes here" />
      <meta name="keywords" content="your,keywords,goes,here" />
      <meta name="author" content="Your Name" />
      <link rel="stylesheet" type="text/css" href="cecilia.css" media="screen,projection" />
      <title>Signup check</title>
    </head>

    <body>
    <div id="wrap">
        <div id="header" style="width: 760px; height: 250px">
            <h1><font color="#FFFFFF">Fanfare St. Cecilia Handel</font></h1>
        </div>

        <div id="leftside">
            <ul class="avmenu">
                <li><a href="http://coding-talk.com/f14/index.html">Startpagina</a></li>
                <li><a href="http://coding-talk.com/f14/fanfare.html">De Fanfare</a>
                <li><a href="http://coding-talk.com/f14/opleiding.html">Opleiding</a></li>
                <li><a href="http://coding-talk.com/f14/vrienden.html">De Vrienden</a></li>
                <li><a href="http://coding-talk.com/f14/musicool.html">Musicool</a></li>
                <li><a href="http://coding-talk.com/f14/fotos.html">Foto's</a></li>
                <li><a href="http://coding-talk.com/f14/login.php">Ledenpagina</a>
                <li><a href="http://coding-talk.com/f14/contact.html">Contact</a></li>
            </ul>
        </div>
        
        <div id="extras">
            <div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<images  src="../images/logo.jpg" height="13%" width="52%" alt="logo"><br><br></div>
            <h2 align="center"><b>Agenda</b></h2></font><br>
            <ul>
                <li><b>6 November</b></br>
                    Uitwisselingsconcert met fanfare Juliana uit Haps</li><br>
                <li><b>20 November</b><br>
                    Intocht Sinterklaas</li><br>
                <li><b>18 December</b><br>
                    Kerstconcert</li>
                <li><b>25 December</b><br>
                    Opluistering eucharistieviering</li>
            </ul>
            <p align="center">voor details zie <a href="http://coding-talk.com/f14/jaarprogramma.html">jaarprogramma </a></p>
        </div>

       <div id="content">
       
    <center>
    <?
    if(isset($todo) and $todo=="post"){

    $status = "OK";
    $msg="";

    // if userid is less than 3 char then status is not ok
    if(!isset($Gebruikersnaam) or strlen($Gebruikersnaam) <3){
    $msg=$msg."Gebruikersnaam dient uit drie of meer letters of cijfers te bestaan.<BR>";
    $status= "NOTOK";}                    

    if(mysql_num_rows(mysql_query("SELECT Gebruikersnaam FROM plus_signup WHERE Gebruikersnaam = '$Gebruikersnaam'"))){
    $msg=$msg."Gebruikersnaam bestaat al, probeer een andere naam.<BR>";
    $status= "NOTOK";}                    


    if ( strlen($Wachtwoord) < 3 ){
    $msg=$msg."Wachtwoord dient uit meer dan drie cijfers of letters te bestaan.<BR>";
    $status= "NOTOK";}                    

    if ( $Wachtwoord <> $Wachtwoord2 ){
    $msg=$msg."Beide wachtwoorden zijn niet gelijk.<BR>";
    $status= "NOTOK";}                    


    if ($agree<>"yes") {
    $msg=$msg."U dient: Het formulier is correct ingevuld aan te vinken.<BR>";
    $status= "NOTOK";}    

    if($status<>"OK"){ 
    echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onClick='history.go(-1)'>";
    }else{ // if all validations are passed.
    $query=mysql_query("INSERT INTO plus_signup (Gebruikersnaam,Wachtwoord,Achternaam,Voorvoegsel,Voornaam,Geboortedatum,Emailadres,Adres,Postcode,Plaats,Telefoon,Mobiel,Instrument) values ('$Gebruikersnaam','$Wachtwoord','$Achternaam','$Voorvoegsel','$Voornaam','$Geboortedatum','$Emailadres','$Adres','$Postcode','$Plaats','$Telefoon','$Mobiel','$Instrument')");
    echo "<font face='Verdana' size='2' color=green>Welkom, u bent succesvol ingeschreven.<br><br><a href=login.php>Klik hier om in te loggen</a><br></font>";
    }
    }
    ?>
    </center>

    </div>


        <div id="footer">
            <p><span>&copy; 2011 Fanfare St. Cecilia</a></span><br /></p>
        </div>

    </div>
    </body>
    </html>
    With kind regards,

    Ad.
    Last edited by Showa; 17.10.11, 08:09. Reason: Wrong signup_ck.php

    #2
    Problem is solved, after posting the thread I discovered a typo. In sign-up check there was E-mailadres with a hyphen. Changing this in Emailadres solved the problem. Took one and a half week to find out. I also posted two times the same script. Does the script look ok?

    With kind regards,

    Ad.

    Comment

    Working...
    X