Page 1 of 1

i need a script to do this...

Posted: Fri Sep 12, 2003 4:34 am
by crisp
This script checks if a pice of data is valid.

Code: Select all

<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>&nbsp;</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>&nbsp;</p>
<form name="TutorCodes" method="post" action="">
  Registration Group code to be checked:&nbsp;&nbsp;&nbsp;&nbsp;
<input name="RegCode" type="text" size="6" maxlength="4">&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="submit" name="Submit" value="Submit">
</form>
<p>&nbsp;</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>&nbsp;</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.

please help

this script can be found at
http://www.haydonbridgehigh.co.uk/Publi ... Groups.php

Posted: Fri Sep 12, 2003 5:55 am
by Black Unicorn
I don't quite understand what you mean by automatically inputting data. If you wish a form to be pre-filled, like:

<input type="text" name="blah" value="[?php echo($somevar); ?]" size="4" />

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?

Regards,
H

Posted: Fri Sep 12, 2003 7:25 am
by Judas
me 2 don't know what you want it 2 do

Posted: Fri Sep 12, 2003 11:04 am
by m3rajk
you need to clarify what exactly you're trying to do... what do you validate for?

i think this can point you ni the right direction:

Code: Select all

<?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;
}
?>

thanks

Posted: Sat Sep 13, 2003 6:52 am
by crisp
its ok ive got it now, thanks anyway.

it was just some pointless task my ict teacher set me.

Posted: Sat Sep 13, 2003 1:11 pm
by m3rajk
so you were asking us to do your homework instead of actually trying anything.

this isn't the forums for that. there's other ones for script kiddies. try one of them next time