Jump to content

Form problem


Recommended Posts

Hi,

 

I have a simple code that sends form contents to a table in my database. However I keep getting this error:

 

An error occurred in script 'C:\wamp\www\html\upload_instructions.php' on line 24:

eregi() [function.eregi]: REG_BADBR

 

Any ideas what is wrong, i'm sure it's something really simple that I have missed.

 

<?php # Script 13.6 - register.php
// This is the registration page for the site.

// Include the configuration file for error management and such.
require_once ('./includes/config.inc.php');

// Set the page title and include the HTML header.
$page_title = 'Upload Instructions';
include ('./includes/header.html');

if (isset($_POST['submitted'])) { // Handle the form.

require_once ('../mysql_connect.php'); // Connect to the database.

// Check for a topic.
if (eregi ('^[[:alpha:]\.\' \-]{2,30}$', stripslashes(trim($_POST['topic'])))) {
	$t = escape_data($_POST['topic']);
} else {
	$t = FALSE;
	echo '<p><font color="red" size="+1">Please enter your topic.</font></p>';
}

// Check for a instructions.
	if (eregi ('^[[:alpha:]\.\' \-]{2,1000}$', stripslashes(trim($_POST['instructions'])))) {
		$i = escape_data($_POST['instructions']);
	} else {
		$i = FALSE;
		echo '<p><font color="red" size="+1">Please enter your instructions.</font></p>';
	}

if ($t && $i) { // If everything's OK.

		// Add the user.
		$query = "INSERT INTO uploaded_instructions (topic, instructions) VALUES ('$t', $i' )";
		$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());

		if (mysql_affected_rows() == 1) { // If it ran OK.

			// Finish the page.
			echo '<h3>Thank you for submitting instructions!</h3>';
			include ('./includes/footer.html'); // Include the HTML footer.
			exit();

		} else { // If it did not run OK.
			echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>';
		}

} else { // If one of the data tests failed.
	echo '<p><font color="red" size="+1">Please try again.</font></p>';
}

mysql_close(); // Close the database connection.

} // End of the main Submit conditional.
?>

<h1>Register</h1>
<form action="upload_instructions.php" method="post">
<fieldset>

<p><b>Topic:</b> <input type="text" name="topic" size="100" maxlength="100" value="<?php if (isset($_POST['topic'])) echo $_POST['topic']; ?>" /></p>

<p><b>Instructions:</b><br><textarea name="instructions" maxlength="1000" rows="30" cols="120" value="<?php if (isset($_POST['instructions'])) echo $_POST['instructions']; ?>" /></textarea> </p>

<div align="center"><input type="submit" name="submit" value="Upload Instructions" /></div>
<input type="hidden" name="submitted" value="TRUE" />

</form>

<?php // Include the HTML footer.
include ('./includes/footer.html');
?>

Link to comment
https://forums.phpfreaks.com/topic/193882-form-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.