Jump to content

[SOLVED] PHP Form Help


BrotherBear

Recommended Posts

Hi

 

I have a contact form and want to verify that all spaces are filled so I putted some code and works the only problem is that when it tells you the error the text appears in the top of the form page and I want it to appear below te space or wherever I want here's the code

$Name = $_POST['Name'];  
$Age = $_POST['Age'];  
$Email = $_POST['Email'];  
$Comments = $_POST['Comments'];  
if 
($Name==0) 
  echo "Please fill the spaces completely"; 
  include ("contactus.html"); 
  exit(); 

 

what can I do to make the error text appear wherever I want?

 

thanks

 

BB

Link to comment
https://forums.phpfreaks.com/topic/44856-solved-php-form-help/
Share on other sites

define the error in a variable and than echo it on ur form

$Name = $_POST['Name'];  
$Age = $_POST['Age'];  
$Email = $_POST['Email'];  
$Comments = $_POST['Comments'];  
if 
($Name==0) 
  $error =  "Please fill the spaces completely"; 
  include ("contactus.html"); 
  exit(); 

 

now inside youe contacus.html page have something like this

 

<input type="text"> <font color="red"><?=$error?></font>

Link to comment
https://forums.phpfreaks.com/topic/44856-solved-php-form-help/#findComment-217842
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.