runnerjp
05-30-2008, 10:35 AM
hey guys i keep getitng the error Undefined index: title
form this line if (($_POST["title"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["title"])))
now im thinkin its 2 things ...1st have i put the bracets for if ($result = mysql_query($query)){
if (mysql_num_rows($result)) {
on the wrong line ( this being here <form id="FormName" action='<?php "$_SERVER[PHP_SELF]" ?>' method="post" name="basic">
<table width="440" border="0" align="center" cellpadding="0" cellspacing="2">
<tr><td colspan="3" align="center" valign="middle"> <p align="center"><?}} ?> )
or that i have written out the code wrong :S
<?php
error_reporting(E_ALL);
require_once '../settings.php';
checkLogin ('1');
$id=$_GET['id'];
$query = "SELECT * FROM forumtutorial_posts where postid='$id'";
if ($result = mysql_query($query)){
if (mysql_num_rows($result)) {
$array = mysql_fetch_assoc($result);
$title = $array['title'];
?>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class= width="30%" height="223" valign="middle" bgcolor="#FFFFFF"><p> </p>
<p> </p></td>
<td width="46%" valign="top" class= align="center" ><table class="headermenu" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?php
function error_bool($error, $field) {
if($error[$field]) {
print("<td style=color:red>");
}
else {
print("<td>");
}
}
function show_form() {
global $HTTP_POST_VARS, $print_again, $error;
?>
<form id="FormName" action='<?php "$_SERVER[PHP_SELF]" ?>' method="post" name="basic">
<table width="440" border="0" align="center" cellpadding="0" cellspacing="2">
<tr><td colspan="3" align="center" valign="middle"> <p align="center"><?}} ?></p>
</td>
</tr>
<tr>
<td><div align="right">
<label for="dob">First name</label>
</div></td>
<td colspan="2"><input class="inputedit" id="title" name="title type="text" size="25" value="<?php echo $title;?>" maxlength="255" /></td>
</tr>
<tr>
<td width="150" align="right">status</td>
<td colspan="2"><?php
}function check_form()
{
global $HTTP_POST_VARS, $error, $print_again;
$error['error'] = false;
{
$error['title'] = true;
$print_again = true;
$message = "The first name field is either empty or incorrect data was input.<br>";
}
if($print_again) {
show_form();
} else {
show_form();
$message="<span class='style1'>Your profile has been created</span>";
$title = mysql_real_escape_string( $_POST['title']);
$update = "UPDATE forumtutorial_posts SET title = '$title' WHERE postid='$id' ";
$result = mysql_query($update);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$er = 'Invalid query: ' . mysql_error() . "\n";
$er .= 'Whole query: ' . $query;
die($er);
}}
echo ' <p class="error">' . $message . '</p>' . "\n";
}
if(isset($_POST["basic"])) {
check_form();
} else {
show_form();
}
?>
</table>
form this line if (($_POST["title"] == "") || (!preg_match("/^[a-z0-9]+(?:_[a-z0-9]+)?$/i", $_POST["title"])))
now im thinkin its 2 things ...1st have i put the bracets for if ($result = mysql_query($query)){
if (mysql_num_rows($result)) {
on the wrong line ( this being here <form id="FormName" action='<?php "$_SERVER[PHP_SELF]" ?>' method="post" name="basic">
<table width="440" border="0" align="center" cellpadding="0" cellspacing="2">
<tr><td colspan="3" align="center" valign="middle"> <p align="center"><?}} ?> )
or that i have written out the code wrong :S
<?php
error_reporting(E_ALL);
require_once '../settings.php';
checkLogin ('1');
$id=$_GET['id'];
$query = "SELECT * FROM forumtutorial_posts where postid='$id'";
if ($result = mysql_query($query)){
if (mysql_num_rows($result)) {
$array = mysql_fetch_assoc($result);
$title = $array['title'];
?>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class= width="30%" height="223" valign="middle" bgcolor="#FFFFFF"><p> </p>
<p> </p></td>
<td width="46%" valign="top" class= align="center" ><table class="headermenu" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?php
function error_bool($error, $field) {
if($error[$field]) {
print("<td style=color:red>");
}
else {
print("<td>");
}
}
function show_form() {
global $HTTP_POST_VARS, $print_again, $error;
?>
<form id="FormName" action='<?php "$_SERVER[PHP_SELF]" ?>' method="post" name="basic">
<table width="440" border="0" align="center" cellpadding="0" cellspacing="2">
<tr><td colspan="3" align="center" valign="middle"> <p align="center"><?}} ?></p>
</td>
</tr>
<tr>
<td><div align="right">
<label for="dob">First name</label>
</div></td>
<td colspan="2"><input class="inputedit" id="title" name="title type="text" size="25" value="<?php echo $title;?>" maxlength="255" /></td>
</tr>
<tr>
<td width="150" align="right">status</td>
<td colspan="2"><?php
}function check_form()
{
global $HTTP_POST_VARS, $error, $print_again;
$error['error'] = false;
{
$error['title'] = true;
$print_again = true;
$message = "The first name field is either empty or incorrect data was input.<br>";
}
if($print_again) {
show_form();
} else {
show_form();
$message="<span class='style1'>Your profile has been created</span>";
$title = mysql_real_escape_string( $_POST['title']);
$update = "UPDATE forumtutorial_posts SET title = '$title' WHERE postid='$id' ";
$result = mysql_query($update);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$er = 'Invalid query: ' . mysql_error() . "\n";
$er .= 'Whole query: ' . $query;
die($er);
}}
echo ' <p class="error">' . $message . '</p>' . "\n";
}
if(isset($_POST["basic"])) {
check_form();
} else {
show_form();
}
?>
</table>