Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Thanked 0 Times in 0 Posts

    College PHP/MYSQL Validation Help :)

    Tried to get this for about three days actually suck at coding and i need to
    do some validation for a database as one of the task's.

    Breif: The php will need some validation of data entry and an INSERT query. The checking of the connection is not enough.

    Programming Code for index:

    PHP Code:
    <!DOCTYPE html>
    titleDatabase Validation</title>
    check(Form1) {
    Firstname Form1.Firstname.value;
    Lastname Form1.Lastname.value;
    dob Form1.dob.value;
    postcode Form1.postcode.value;
    Firstname.length == 0) {
    alert("Enter a valid firstname and try again");
    Lastname.length == 0) {
    alert("Enter a valid lastname and try again");
    dob.length == 4) {
    alert("Date of birth error go back and try again");
    postcode.length == 0) {
    alert("Please enter a valid postcode and try again. ");
                else {
    alert("Sorry but you have not entered the correct information to check against the database.")

        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
    body,td,th {
        color: #FFFFFF;
    body {
        background-color: #000000;

        <form id="form" action="check.php" method="POST" onSubmit="return check(this)">
                <div align="center"><br>
                  Form Validation <br>
          <label>First Name: <input type="text" id="Firstname"></label>
                <label>Forename : 
                <input type="text" id="Lastname"></label>
                <label>Date Of Birth: <input type="date" id="dob"></label>
                <label>Post Code: <input type="text" id="postcode"></label>
                <input type="submit" value="Submit" id="submit" >
    i basically need the check.php making so that it checks the validation of the data entered into this form on index.php and if it does not match what is found in the database it returns an error.

    Copy of the database is located here: http://dl.dropbox.com/u/27402420/Col...risLeisure.sql

    if somebody can do this for me you will be helping me out pretty hast im currently in college and this is all i need for this unit to pass it.

  2. #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Winona, MN - The land of 10,000 lakes
    Thanked 45 Times in 42 Posts
    No one will do your homework for you, but I will tell you the basic concepts...

    First, establish a connection to the database.
    Then read the submitted data ($_POST superglobal)
    Clean up data
    Query the database for a result
    Compare result to the submitted data
    Take an action based on the result comparison

    You'll need to produce the code and ask more specific questions to get more help.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts