Link to home
Start Free TrialLog in
Avatar of peter_coop
peter_coopFlag for United Kingdom of Great Britain and Northern Ireland

asked on

variable help needed

i am trying to display an error message if a client fails to select a service. although the code i have attached works, it only works by displaying the message way off the page in the top of the page. i would like it to appear in a place i designate more on the page. is this possible? many thanks
//From submitted form
 
$prez = $_POST['prez'];
 
 
 
//Need to error check before mailing
 
<?php
if (!isset($_POST['prez']) || (empty($_POST['prez'])==' '))
{
$error = '<span style="color:red">You must select a Service</span>';
}
else 
{
$to = "whoever@coldmail.com";
$subject = "Sales Enquiry";
$message = "You have an enquiry from $name for local services.\n\nName: $name\n\nAddress1: $address1\n\naddress2: $address2\n\nTown: $town\n\nPostcode: $postcode\n\nDescription: $description\n\nTelephone: $telephone\n\nContact By: $contact\n\nService: $prez";
$headers = "From: $email";
mail($to, $subject, $message, $headers); 
}
?>

Open in new window

Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

There is not enough code there to tell what is wrong. Can you please post the code for the ENTIRE pages, both the form and action? Thanks, ~Ray
ASKER CERTIFIED SOLUTION
Avatar of Tagor
Tagor

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of peter_coop

ASKER

@Ray_Paseur

Totally lost with your solution.

@Tagor

Your code does not work.

<?php echo $error ; ?> is blank on the page.

any other ideas?

many thanks for your input.
@peter_coop: You have some responsibility here at EE to at least try to understand the technologies that you are trying to use, and unless I am completely misreading your question this is an elementary issue.

The script I posted is VERY elementary - PHP 101.  Please forgive me for repeating myself, but "Install it and run it to see how it works."  Then post something in the form of a question - we can help if we work together on the issues.

Don't know why you did not post the complete scripts you are using, but if you do, that will be helpful, too.

Best regards, ~Ray
thx once again
Please read the grading guidelines here:
https://www.experts-exchange.com/help.jsp#hi403

I think you owe us an explanation why you marked the answers down to a "B" without any comment.  It would have been helpful if you had posted the code we asked for, and in the absence of that, it seems inappropriate to give an inferior grade.  It costs you nothing more to give the right grade according to the standards of EE.

You can ask a moderator to change the grade to "A" or you can explain why you believe, in the context of the EE grading system, that the answers did not deserve an "A".

Thanks for your consideration, ~Ray