Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-04-2012, 01:56 PM   PM User | #1
Snorts
New to the CF scene

 
Join Date: Jul 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Snorts is an unknown quantity at this point
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>
<
html>
    <
head>
        <
titleDatabase Validation</title>
    <
script>
        function 
check(Form1) {
            var 
Firstname Form1.Firstname.value;
            var 
Lastname Form1.Lastname.value;
            var 
dob Form1.dob.value;
            var 
postcode Form1.postcode.value;
            if(
Firstname.length == 0) {
                
alert("Enter a valid firstname and try again");
            }
            if(
Lastname.length == 0) {
                
alert("Enter a valid lastname and try again");
            }
            if(
dob.length == 4) {
                
alert("Date of birth error go back and try again");
            }
            if(
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.")
            }
        }


            
</script>
    <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;
}
-->
</style></head>
    <body>

    <form id="form" action="check.php" method="POST" onSubmit="return check(this)">
            <div align="center"><br>
              Form Validation <br>
            </div>
      <label>First Name: <input type="text" id="Firstname"></label>
<br>
            <label>Forename : 
            <input type="text" id="Lastname"></label>
<br>
            <label>Date Of Birth: <input type="date" id="dob"></label>
<br>
            <label>Post Code: <input type="text" id="postcode"></label>
            <input type="submit" value="Submit" id="submit" >
            <br><br>
<br>
    </form>
    </body>
</html> 
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.
Snorts is offline   Reply With Quote
Old 07-04-2012, 05:12 PM   PM User | #2
bcarl314
Mega-ultimate member


 
Join Date: Jun 2002
Location: Winona, MN - The land of 10,000 lakes
Posts: 1,855
Thanks: 1
Thanked 45 Times in 42 Posts
bcarl314 will become famous soon enough
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.
bcarl314 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:04 PM.


Advertisement
Log in to turn off these ads.