Form submission oddities!

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!

Moderator: General Moderators

Post Reply
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

Form submission oddities!

Post by lettie_dude »

Hi

Anyone ever come across this problem before.

I have a form that edits a news story the form populates fine from the database info. And all the required processing checks pass fine. However unless I actually change the first form input field and enter completely new data the form does not process and goes to my error message for unable to process.

For example:

The title of the story may be 'News Test 2'. This is the first input field on the form. Now unless this is changed to something else. i.e. 'News Test Two' the form will not work and the database is not updated.

I am going off my box here as the code is the same for every other form input field and it works fine if you change the title to something else! Anyone come across this perculiarity before?

Code: Select all

if(isset($_POST['newstitle'])) {

     if(eregi("^[a-zA-Z0-9 ]{5,50}$", trim($_POST['newstitle']))) {
	$clean['title'] = stripslashes($_POST['newstitle']);
     } else {
	$clean['title'] = FALSE;
	$msg .= '<p class="text"><font color="red">Please enter the news title!</font></p>';
     }

} else {
          $msg .= '<p class="text"><font color="red">Please enter the news title!</font></p>';
          $clean['title'] = FALSE;
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

No, I have not run into such a problem.

Care to post your form?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Where's the rest of the processing code? I have run into problems with UPDATE queries where the data that is being updated has not changed, and, since I was checking against affected_rows(), the return from the DB was 0 and my error tiggered. It is not exactly the same as what you are going through, but I'd be interested to see all of the code.
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

Post by lettie_dude »

I'll re-jig the code for you and post a modified version so you can have a look at it.
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

Resolved

Post by lettie_dude »

Cheers Everah

Checked on the database submission and was also using affected_rows. I have resolved this myself but what solution did you put in place to combat this?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I checked against two things instead of one. I ran the query through mysql_query(), then, if that did not error, I ran it through mysql_affected_rows(). If that did not return false, i proceeded with what I was doing, otherwise I did something else knowing the data never changed.
Post Reply