Conditional Submit ... - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-28-2008, 02:43 PM   #1 (permalink)
Regular User
 
Join Date: Nov 2008
Posts: 20
Default Conditional Submit ...

Hello:

I am trying to change the action portion of my form based on criteria, in this case if the counter is equal to 14 then load thankyou.php, else continue on the PHP Self. What this is is a application form that tests whether all the data is okay. I will work on the santizing later but wanted to get this done as it seems to be the hardest, at least for me.


<?php
$frmSubmit = "";
$errFName = "";

if($_POST["ac"]=="login")
{
// If First Name is NOT letters, dash or spaces then display error message.
if(preg_match("/^[A-Z][a-zA-Z -]+$/", $_POST["fname"]) === 0)
$errFName = '<class="errText">First name must be from letters, dashes, spaces and must not start with dash';
else
$frmCounter = $frmCounter + 1;
// Add validation & Santization here
// more of the above ...
// more of the above ...
// more of the above ...
// more of the above ...

if $frmCounter = 14
$frmSubmit = ThankYou.php;
else
$frmSubmit = $PHP_SELF;

}

?>

<body>

<form name="main" action="<?php $frmSubmit ?>" method="POST"><input type="hidden" name="ac" value="login">
pepe_lepew1962 is offline   Reply With Quote
Sponsored Links
Old 01-03-2009, 01:36 AM   #2 (permalink)
Junior Member
 
DigitaLink's Avatar
 
Join Date: Sep 2008
Posts: 10
Default Re: Conditional Submit ...

I think what you're looking for is $_SERVER['PHP_SELF'], not $PHP_SELF.

$PHP_SELF won't give you any value. It's a server variable. I suppose you could use $PHP_SELF if you first did an extract($_SERVER);, but it's safer and easier to just use $_SERVER properly.
DigitaLink is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 07:33 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting