>From: "Daniel Guerrier" <[EMAIL PROTECTED]> >Sent: Saturday, August 10, 2002 12:14 PM >Subject: [PHP] PHP form port
> How do i execute a form post with php? > I want to validate CCard info etc.. then perform the > post with no furtheraction from the user. > > Basically If not valid stay here and show whats wrong > ELSE post form to process.php Sorry, I mis-understood your question. PHP is server-side, so you have to post the form to validate. The way I handle the situation you have is to have the same script process the form for both the initial request (method=get) and the form post (method=post). If 'POST' == $_SERVER['REQUEST_METHOD'], then validate. If validation passes, process the transaction, and redirect with header() to a new page. if it fails, make use the prior supplied data in input values so you retain the input from the person using your form. Example: <?php if ('GET' == $_SERVER['REQUEST_METHOD']) $name=''; $location=''; } if ('POST' == $_SERVER['REQUEST_METHOD']) { $errors = validate(); if (empty($errors()) { process_form(); redirect(); } $name = trim($_POST['name']); $location = trim($_POST['location']); } ?> <form method="post" action="<?php echo {$_SERVER['PHP_SELF']}; ?> "> <input type="text" name="name" value="<?php echo $name; ?> "> <input type="text" name="location" value="<?php echo $location; ?> "> <input type="submit" name="submit" value="Submit"> </form> HTH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php