Jump to content

Edit Text Error Why?


laado
 Share

Recommended Posts

its a code of edit text. bt when i edit text with numbers it cannot display error and msg displyed that text edit successfully. but the text not edited. why?following is the code:

<title>Edit News</title><?php//LAST UPDATE// 27-09-2007include("config.php");$error = "";$error1 = "";$error2 = "";$error3 = "";$error4 = "";$error5 = "";   $newsid = $_GET['newsid'];   if(isset($_POST['submit']))  {	  $title = $_POST['title'];	  $text1 = $_POST['text1'];	  $text2 = $_POST['text2'];//check if (title) field is empty then print error message.			  if(!$title){  //this means If the title is really empty.					 $error = "Error: News title is a required field. Please fill it.";	   			   }// end of if			  elseif ((bool) preg_match('/[0-9]/', $title)) {				 $error3 = "Error: News title must not contain numbers. Please refill it, with all numbers removed.";				 			   }			  elseif(!$text1){  //this means If the title is really empty.					 $error1= "Error: News text1 is a required field. Please fill it.";							}			  elseif ((bool) preg_match('/[0-9]/', $text1)) {				 $error4 = "Error: News title must not contain numbers. Please refill it, with all numbers removed.";				 			   } 			  elseif(!$text2){  //this means If the title is really empty.					 $error2= "Error: News text2 is a required field. Please fill it.";			   			   }	  	 elseif ((bool) preg_match('/[0-9]/', $text2)) {				 $error5 = "Error: News title must not contain numbers. Please refill it, with all numbers removed.";				 			   }		 $result = mysql_query("UPDATE news SET title='$title', text1='$text1', text2='$text2' WHERE newsid='$newsid' ",$connect);		  echo "<b>Thank you! News UPDATED Successfully!<br>You'll be redirected to Home Page after (4) Seconds";		  echo "<meta http-equiv=Refresh content=4;url=index.php>";}elseif($newsid){		$result = mysql_query("SELECT * FROM news WHERE newsid='$newsid' ",$connect);		while($myrow = mysql_fetch_assoc($result))			 {				$title = $myrow["title"];				$text1 = $myrow["text1"];				$text2= $myrow["text2"];?><br><h3>::Edit News</h3><form method="post" action="<?php echo $PHP_SELF ?>"><input type="hidden" name="newsid" value="<? echo $myrow['newsid']?>">Title: <input name="title" size="40" maxlength="255" value="<? echo $title; ?>"><?php echo $error ?> <?php echo $error3 ?><br>Text1: <textarea name="text1"  rows="7" cols="30"><? echo $text1; ?></textarea><?php echo $error1 ?> <?php echo $error4 ?><br>Text2: <textarea name="text2" rows="7" cols="30"><? echo $text2; ?></textarea> <?php echo $error2 ?> <?php echo $error5 ?><br><input type="submit" name="submit" value="Update News"></form><?			  }//end of while loop  }//end else?>

please tell me where is the error why it should not displayed error?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...