Still some issues

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

    Still some issues

    Hello,
    Everything is beginning to work, but there are still a few issues left.
    Please forgive my ignorance and hence stupid questions (Newbie).
    I can now enter data with no problem, I get no errors, however, when I
    check the contents of my DB, 2 fields display nothing.
    The Fields PostCode (VARCHAR(10)) NOT NULL and
    Email (VARCHAR(80)) NOT NULL
    both remain empty in the database although I have entered data.
    Like I said, I get no error messages after completion of the form.
    If it helps, here is the PHP file to enter everything:
    <html>
    <head><title>Te st MySQL</title></head>
    <style>
    body{
    scrollbar-arrow-color: #00FF00;
    scrollbar-3dlight-color: #333333;
    scrollbar-highlight-color: #33FF33;
    scrollbar-face-color: #000000;
    scrollbar-shadow-color: #00CC00;
    scrollbar-darkshadow-color: #000000;
    scrollbar-track-color: #000000;


    }
    </style>
    <body bgcolor="#00000 0" text="#00FF00" link="#FFFF00" vlink="#CCFFFF"
    alink="#99CC00" >
    <!-- mysql_up.php -->
    <?php
    $host="everyweb host.com";
    $user="radiokvo _enrol";
    $password="**** ******";
    mysql_connect($ host,$user,$pas sword);
    mysql_select_db ($user);
    $Name=$_POST['Name'];
    $FirstNames=$_P OST['FirstNames'];
    $DOB=$_POST['DOB'];
    $Sex=$_POST['Sex'];
    $Address=$_POST['Address'];
    $Town=$_POST['Town'];
    $County=$_POST['County'];
    $PostCode=$_POS T['PostCode'];
    $Telephone=$_PO ST['Telephone'];
    $Mobile=$_POST['Mobile'];
    $Fax=$_POST['Fax'];
    $Email=$_POST['Email'];
    $Course=$_POST['Course'];
    $OtherCourse=$_ POST['OtherCourse'];
    $SessionType=$_ POST['SessionType'];
    $OtherDuration= $_POST['OtherDuration'];
    $NumberOfStuden ts=$_POST['NumberOfStuden ts'];
    $query = "INSERT into Names
    (Name,FirstName s,DOB,Sex,Addre ss,Town,County, PostCode,Teleph one,Mobile,Fax, Email,Course,Ot herCourse,Sessi onType,OtherDur ation,NumberOfS tudents)
    VALUES
    ('$Name','$Firs tNames','$DOB', '$Sex','$Addres s','$Town','$Co unty','$PostCod e','$Telephone' ,'$Mobile','$Fa x','$Email','$C ourse','$OtherC ourse','$Sessio nType','$OtherD uration','$Numb erOfStudents')" ;
    $result = mysql_query($qu ery)
    or die ("Couldn't execute query");
    ?>
    </body>
    </html>

    And this is the form HTML code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <!-- Created with the CoffeeCup HTML Editor 2005 -->
    <!-- http://www.coffeecup.com/ -->
    <!-- Brewed on 15/08/2005 15:31:15 -->
    <head>
    <title>Enrolmen ts</title>
    <meta name="generator " content="Coffee Cup HTML Editor 2005D -
    www.coffeecup.c om">
    <meta name="descripti on" content="">
    <meta name="keywords" content="">
    <style>
    body{
    scrollbar-arrow-color: #00FF00;
    scrollbar-3dlight-color: #333333;
    scrollbar-highlight-color: #33FF33;
    scrollbar-face-color: #000000;
    scrollbar-shadow-color: #00CC00;
    scrollbar-darkshadow-color: #000000;
    scrollbar-track-color: #000000;
    }
    </style>
    </head>
    <body bgcolor="#00000 0" text="#00FF00" link="#FFFFFF" vlink="#33CCCC"
    alink="#FF0000" >
    <div align="center"> <font size="5">The Enrolment Page</font></div><br>
    On this page you can enrol online, or, if you have already registered by
    phone or other means, pass on your details so we can adjust our
    database.<br>
    Just fill in the fields in the form below, and you will get a
    confirmation e-mail when it is
    all done.<br>
    <PRE><!-- Start of FORM -->
    <form method="POST" action="http://enrolling.mybes thost.com/enrol.php">
    Name: <input type="text" name="Name" Size="50"><br>
    First Name(s): <input type="text" name="FirstName s" Size="60"><br>
    Date of Birth: <input type="text" name="DOB" value=""> (YYYY-MM-DD)<br>
    Sex: <select name="Sex">
    <option value="Female"> Female
    <option value="Male">Ma le
    </select><br>
    Address: <input type="text" name="Address" Size="70"><br>
    Town: <input type="text" name="Town" Size="40"><br>
    County: <input type="text" name="County" Size="15"><br>
    Postcode: <input type="text" name="Postcode" Size="15"><br>
    Telephone: <input type="text" name="Telephone " Size="30"><br>
    Mobile: <input type="text" name="Mobile" Size="30"><br>
    Fax: <input type="text" name="Fax" Size="30"><br>
    E-mail: <input type="text" name="E-mail" Size="70"><br>
    Course: <input type="checkbox" name="Course" value="Piano"> Piano<br>
    <input type="checkbox" name="Course" value="Keyboard ">
    Keyboard<br>
    <input type="checkbox" name="Course" value="Singing" > Singing<br>
    <input type="checkbox" name="Course" value="Other"> Other<br>
    (If "Other", please specify:)<br>
    <input type="text" name="OtherCour se" Size="60"><br>
    Session: <select name="SessionTy pe">
    <option value="1 hour"> 1 hour
    <option value="30 minutes"> 30 minutes
    <option value="5 trial 1 hour"> 5 trial lessons @ 1 hour
    <option value="5 trial 30 minutes"> 5 trial lessons @ 30 minutes
    <option value="Other"> Other
    </select><br>
    (If "Other", please specify :)<br>
    <input type="text" name="OtherDura tion" Size="40"><br>
    No of students:<input type="text" name="NumberOfS tudents" Size="4"><br>
    <input type="submit"> <input type="reset">
    </form>
    <!-- End of FORM --></pre>
    <body>
    </html>

    In order not to be a pain, I will ask about the other issues later and
    try to get this one sorted first.
    All help will be much appreciated.
  • Gordon Burditt

    #2
    Re: Still some issues

    >Everything is beginning to work, but there are still a few issues left.[color=blue]
    > Please forgive my ignorance and hence stupid questions (Newbie).
    >I can now enter data with no problem, I get no errors, however, when I
    >check the contents of my DB, 2 fields display nothing.
    >The Fields PostCode (VARCHAR(10)) NOT NULL and
    > Email (VARCHAR(80)) NOT NULL
    >both remain empty in the database although I have entered data.[/color]

    '' is a valid content of a VARCHAR(10) field.

    You have no input field for 'PostCode' in your form.
    You have no input field for 'Email' in your form.


    [color=blue]
    >Like I said, I get no error messages after completion of the form.
    >If it helps, here is the PHP file to enter everything:[/color]

    Add the statement:
    echo $query;
    right before the call to mysql_query. Show us what it prints
    when it does something you think is wrong. This will separate
    MySQL issues vs. PHP and HTML issues.

    Gordon L. Burditt

    Comment

    • Newsscanner

      #3
      Re: Still some issues

      Gordon Burditt wrote:[color=blue]
      > '' is a valid content of a VARCHAR(10) field.
      >
      > You have no input field for 'PostCode' in your form.
      > You have no input field for 'Email' in your form.[/color]
      Managed to miss that somehow.
      Fixed it now.
      Thanks.
      [color=blue]
      > Add the statement:
      > echo $query;
      > right before the call to mysql_query. Show us what it prints
      > when it does something you think is wrong. This will separate
      > MySQL issues vs. PHP and HTML issues.
      >
      > Gordon L. Burditt[/color]
      Here we go for the next one: I have one field with a choice via
      checkboxes (where more than 1 choice is possible), I would like to see
      all the fields (if users select multiple options of course) filling the
      'Course' field, eg. if someone selects as their course Piano and also
      Singing, I would like to see in my DB in the 'Course' field something
      like "Piano, Singing".
      I am not really sure where I am going wrong here.
      The data type for this field is VARCHAR.

      Thanks,
      Newsscanner.

      Comment

      • Bill Karwin

        #4
        Re: Still some issues

        Newsscanner wrote:[color=blue]
        > Here we go for the next one: I have one field with a choice via
        > checkboxes (where more than 1 choice is possible), I would like to see
        > all the fields (if users select multiple options of course) filling the
        > 'Course' field, eg. if someone selects as their course Piano and also
        > Singing, I would like to see in my DB in the 'Course' field something
        > like "Piano, Singing".[/color]

        Here's an article with example on using PHP to accept input from form
        fields that have multiple values:


        Once you have them in your PHP code as an array object, use implode() to
        make a single comma-separated string out of the elements in the array.
        See http://us3.php.net/implode

        Then you have a string you can use to insert into your VARCHAR field.

        Regards,
        Bill K.

        Comment

        Working...