FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Need Help on creating a validation script





robertcahill
Please I need help with creating a php script that redirects users to a new page by validating certain records in mysql database.

Example:
in the mysql data table CLient ID is 2 and clientname is james.

how do i make a php script to redirect to google.com if client ID is urlid and client name is james from the db.

Thank you for your help.
rx9876
this will do.

Code:

header("Location: http://www.google.com/");
robertcahill
thank you but what i need is how to make the field to be an enum with either value 1 for james and 0 for not james then again to querry the database and set the values of the active to a variable and possibly set it as a session object then creat an IF and else statement to redirect
jmraker
If you want the field "clientname" to be an enum in mysql you are limited to the names in the list.

The code below
. Changes the field in the table to an ENUMerated list of values
. Selects the first record with a clientname of "james"
. It puts the record in the variable $record and the session as $_SESSION['record']

Code:
<?php

/// connect to database here

session_start();

mysql_query('ALTER TABLE client CHANGE clientname ENUM("not james", "james") DEFAULT "not james"');

$res = mysql_query('SELECT * FROM client WHERE clientname = "james" LIMIT 1');
$_SESSION['record'] = $record = mysql_fetch_assoc($res);

if($record !== false){  // The record of "james" was found
   echo "James was found";
   print_r($record);
}
else{
   header('Location: http://www.google.com/');
   exit();
}

?>


http://dev.mysql.com/doc/refman/5.0/en/constraint-enum.html

Using an ENUM data type for first or last names usually is not a good idea.
Related topics
Flash - Photo Gallery - need help please.
Some questions
Need help with php script
Need help making logout script
Need help with PHP script[RESOLVED]
javascript help. creating new element only when clicked
Need help with logger script. (half done)
need help with a script
need help with a script for vb its not to hard i think
Help creating meebo.com like site in php (yahoo msg part)
Why blurring sensitive information is a bad idea
Login System Tutorial Part 1 Creating Registration
Making a PHP filemanager *finished*
Email Validation script
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.