473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

conditional posting of a record

Hi all

I would be grateful if you could help me in the following issue. I have a form on which I can recall records and modify them. On clicking on the push button 'post', the modified record is updated and a page called guarantee.php is called. But now I want to add some validation so that if there's a mistake in an input field e.g. 'tan' the message 'invalid input' is displayed and instead of calling the program guarantee.php, I am allowed to correct the mistake and post again. If all mistakes are corrected, on clicking post I should go back to guarantee.php but if not the error message should be displayed and I should be allowed to correct. Below are some codes which I have used to return to guarantee.php program after posting. It includes some functions, the description of which I have given in comment form.I have to modify these codes to allow me to correct the mistake and post again. Please help.


[PHP]<? function editrec($recid)
{
$res = sql_select(); // a function that selects the record to be edited
$count = sql_getrecordcount(); // a function that gets the numbver of records in the table
mysql_data_seek($res, $recid);
$row = mysql_fetch_assoc($res);
showrecnav("edit", $recid, $count); //a function creating the navigation tools depending on the no of records
?>
<br>
<form action="guarantee.php" method="post" name="frmcampaign">
<input type="hidden" name="sql" value="update"> //the value "update" of sql is passed to a function to enable update of a record
<input type="hidden" name="xBkg_SerialNo" value="<? echo $row["Bkg_SerialNo"] ?>">
<? showroweditor($row) ?> // displays the fields to be edited
<p><input type="submit" name="action" value="Post"></p>
</form>
<?
mysql_free_result($res);
} ?>[/PHP]

Thanks
Jul 2 '07 #1
5 1483
Hi,
If I have understand what you need you could use another way.
You can use Spry Ajax(opensurce from adobe labs) and you can inset forms that doesn't allow you to continue(to your 2nd page in php) unless the value respects some standard(that you can edit such as int value, minimal/maximal long and so on...). All in jscript.
Hope to have been useful
Jul 2 '07 #2
Sorry but i am a newbie and don't know javascript. Is there no other way.
Jul 2 '07 #3
pbmods
5,821 Expert 4TB
Heya, sharmilah.

Is the PHP code on the same page as the form's HTML?
Jul 2 '07 #4
kovik
1,044 Expert 1GB
When you submit the form, your code should check all fields for validity before any submission is complete.

Example:

Expand|Select|Wrap|Line Numbers
  1. if(!empty($_POST)) // A form has been submitted
  2. {
  3.     if(!isset($_POST['name'], $_POST['email'], $_POST['password']))
  4.     {
  5.         // Create an error message displaying that the form
  6.         //    is incomplete
  7.     }
  8.     else if(strlen($_POST['name']) < 8)
  9.     {
  10.         // Create error message displaying that the name is too short
  11.     }
  12.     else if(!preg_match(/* email regex */, $_POST['email']))
  13.     {
  14.         // Create error message regarding invalid email address
  15.     }
  16.     else
  17.     {
  18.         // Submit the data
  19.     }
  20. }
Jul 2 '07 #5
Motoma
3,237 Expert 2GB
Have your guarantee page perform the validation, and redisplay the form if the data is bad. Then the page can post to itself and you don't have to worry about automating posts between pages.
Jul 2 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Bob | last post by:
I need to know if there is a better way to construct this SQL statement. (Error handling is omitted) MS SQL Server 2000 Insert into FSSUTmp Select a.acct_no, a.ac_nm, a.ac_type, 10, -1, -1...
4
by: Prakash Wadhwani | last post by:
I have 3 fields : First_Name, Last_Name & Policy_Number I'm using a continuous form. If I invoke conditional formatting on First_Name & set a condition of "Prakash" (change the foreground to...
6
by: Allan Koch | last post by:
Dear NG, I would like to format a record in a subform, dependent on a value in one field. If one field in the record I show in a subform (datasheet view) is true I like to view that particular...
4
by: Bradley | last post by:
I have an A2000 database in which I have a continuous form with a tick box. There is also a text box with a conditional format that is based on the expression , if it's true then change the...
8
by: Dimitri Furman | last post by:
Given: Access 2002/2003 A subform in datasheet or continuous view, placed on a tab page (this last may or may not matter) Conditional formatting applied to some controls on the subform - format...
1
by: John | last post by:
My report is based off of a table. I need a record on the report to be highlighted if that record ID is in a different table. Something like, if record ID exists in Query X, then conditional format...
3
by: Chuck Reed | last post by:
I am working on a sales report where I show weekly sales by category for each of the 52 weeks in the year. Each record in my table/report has the 52 weeks of sales in it. I want to highlight to top...
2
by: jodyblau | last post by:
I'm not certain that what I am trying to do is possible; in any event I haven't been able to figure it out. Here is what I am trying to do: I have one table that has a list of cases I'm working...
11
by: tg989 | last post by:
Okay, here goes. Continuous forms... possibly the best feature of access. The only downside is this: the only way to have a conditional evaluation run on each record invididually is by...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.