PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<html>
<head>
<title>HBHS Forms - Testing Plans</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h1>Haydon Bridge High School - Tutor Group Validation</h1>
<p> </p>
Use the form below to enter the register code for a tutor group at HBHS. When
you press Submit the entry will be checked by some code on the server and a
verdict of "Confirmed" or "Rejected" will appear.<p> </p>
<form name="TutorCodes" method="post" action="">
Registration Group code to be checked:
<input name="RegCode" type="text" size="6" maxlength="4">
<input type="submit" name="Submit" value="Submit">
</form>
<p> </p>
<p>By compiling a list of test data and recording the results obtained from
this page you should be able to determine whether the system is working correctly.</p>
<p> </p>
<p>Your test data should include typical, extreme and erroneous examples to fully
test the range of possible input.</p>
</body>
</html>
i need a way of automaticaly inputing the data and retrieving the output ether acepted or rejected.
Checking code can be hard or easy, depending what you want to check it against ... database entry, formatting rule or text file, if you could be more specific?
<?php
session.start(); // if you use sessions
include('/path/to/included/functions.php'); // if you have includded files
$errors=array();
/* do preg or other error checking */
if (!(preg_match('/^\d$/', $_POST['goup_number']))){ // if it's not numeric
$errors[]="your group number is invalid"; // return an error
}
if (!(preg_match('/^[-\w\.]+$/', $_POST['user_name']))){ # username has something other than [A-Za-z0-9_-.]
$errors[]="your username is not valid";
}
/* more error checking */
if(isset($_POST['some_required_variable'])&&(count($errors)==0){ // nothing's wrong
/* process form */
}else{// have the user fill out the form
/* use heredoc format to make the page */
echo <<<END
<html>
<head><!-- header info goes here--></head>
<body>
<center>
END;
foreach($errors as $error){ # for each error
echo "<br /><font color="#FF0000">$error</font>"; // display the error
}
echo <<<END
<form action ="$_SERVER[PHP_SELF]" method="POST">
<br />your name: <input name="user_name" type="text" value="$_POST['user_name']">
<br />your group number: <input name="group_number" type="text" value="$_POST['group_number']">
<!-- the rest of your form here -->
</form>
</body>
</html>
END;
}
?>