when not posting all vars- help to elimnate warnings
Posted: Mon May 07, 2007 2:42 pm
feyd | Please use
The problem arises when each form calls the common module which contains the code above. To follow the example set above, "when Form 1 calls the common module the line of code for $provision2 thru $provision6 all create a warning that the 'ProvisionX' is missing. The warning is "PHP Notice Undefined Index".
Is there a conditional line of code that could pretest the data that is passed or not, then if so passed then allow the corresponding assignment statement to be run. In pseudo code it might look like this,
We have a six individual forms in which the user places information that is passed to a common php script. As an example Form 1 has the Name & Email plus a Message. In addition it has a provision that needs to be passed which is called Provision1. Example Form 2 has all of Name & Email plus a message as well. In addition it has a provision that needs to be passed which is called Provision2. The same for the remainder of the Forms 3 thru 6 and the Provisions3 thru Provisions6. The code to receive those Posted vars is shown below.
If the $HTTP_POST_VARS_EXISTS['Xvalue'] is not in existence are there any classes that might perform the same function? Doing some error handling might also provide similar results. Are there some simple error handling classes?
Thanks for your attention and hope someone is able to help me.
cperg
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
We have a six individual forms in which the user places information that is passed to a common php script. As an example Form 1 has the Name & Email plus a Message. In addition it has a provision that needs to be passed which is called Provision1. Example Form 2 has all of Name & Email plus a message as well. In addition it has a provision that needs to be passed which is called Provision2. The same for the remainder of the Forms 3 thru 6 and the Provisions3 thru Provisions6. The code to receive those Posted vars is shown below.Code: Select all
include("db.php");
$name = $HTTP_POST_VARS['Name'];
$email = $HTTP_POST_VARS['Email'];
$message = $HTTP_POST_VARS['Message'];
$provision1 = $HTTP_POST_VARS['Provision1'];
$provision2 = $HTTP_POST_VARS['Provision2'];
$provision3 = $HTTP_POST_VARS['Provision3'];
$provision4 = $HTTP_POST_VARS['Provision4'];
provision5 = $HTTP_POST_VARS['Provision5'];
$provision6 = $HTTP_POST_VARS['Provision6'];
$message = stripslashes($message);The problem arises when each form calls the common module which contains the code above. To follow the example set above, "when Form 1 calls the common module the line of code for $provision2 thru $provision6 all create a warning that the 'ProvisionX' is missing. The warning is "PHP Notice Undefined Index".
Is there a conditional line of code that could pretest the data that is passed or not, then if so passed then allow the corresponding assignment statement to be run. In pseudo code it might look like this,
We have a six individual forms in which the user places information that is passed to a common php script. As an example Form 1 has the Name & Email plus a Message. In addition it has a provision that needs to be passed which is called Provision1. Example Form 2 has all of Name & Email plus a message as well. In addition it has a provision that needs to be passed which is called Provision2. The same for the remainder of the Forms 3 thru 6 and the Provisions3 thru Provisions6. The code to receive those Posted vars is shown below.
Code: Select all
include("db.php");
$name = $HTTP_POST_VARS['Name'];
$email = $HTTP_POST_VARS['Email'];
$message = $HTTP_POST_VARS['Message'];
if ($HTTP_POST_VARS_EXISTS['Provision1'])
$provision1 = $HTTP_POST_VARS['Provision1'];
if ($HTTP_POST_VARS_EXISTS['Provision2'])
$provision2 = $HTTP_POST_VARS['Provision2'];
if ($HTTP_POST_VARS_EXISTS['Provision3'])
$provision3 = $HTTP_POST_VARS['Provision3'];
if ($HTTP_POST_VARS_EXISTS['Provision4'])
$provision4 = $HTTP_POST_VARS['Provision4'];
if ($HTTP_POST_VARS_EXISTS['Provision5'])
$provision5 = $HTTP_POST_VARS['Provision5'];
if ($HTTP_POST_VARS_EXISTS['Provision6'])
$provision6 = $HTTP_POST_VARS['Provision6'];
$message = stripslashes($message);If the $HTTP_POST_VARS_EXISTS['Xvalue'] is not in existence are there any classes that might perform the same function? Doing some error handling might also provide similar results. Are there some simple error handling classes?
Thanks for your attention and hope someone is able to help me.
cperg
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]