php INSERT INTO SQL input name only one way example Hughes, p

Hi is there a way i can force the user to input a name in a perticular order and if not dissalow them

HTML FORM

[code]

 
Pease enter Teachers Name Example follows (Hughes, P) 
Teachers Name:     
[/code]

PHP INCERT SCRIPT
[php]<?php

// Read values from form using $_POST (safest)

$fname=$_POST[“vname”];

// Connect to server
// Replace username and password by your details

$db = @mysql_connect(“localhost”,“root”,“iqonr301”);
if (!$db)
{
do_error(“Could not connect to the server”);
}

// Connect to the database
// Note that your database will be called username

@mysql_select_db(“test”,$db)or do_error(“Could not connect to the database”);

// Run query

$sql=“INSERT INTO teacher (name) values (’$fname’)”;

if (mysql_query($sql,$db))
{
echo “The following Teacher”;
echo “
Record: $fname has been added to
database.

”;
}
else
{
do_error(“Failed to add record”);
}

function do_error($error)
{
echo $error;
die;
}

?> [/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service