iarp Posted September 18, 2008 Share Posted September 18, 2008 Hey, index.php switch($_GET['action']) { case 'contact-form': contactForm($_POST['name'], $_POST['email'], $_POST['phone'], $_POST['subject'], $_POST['comments']); break; } contactform function ...... cut everything above to save space. if (empty($errors)) { //if everythings ok //Send e-mail with comments $body = "Name: " . $name . "\nPhone: " . $phone . "\nE-mail: " . $email . "\n\n" . $comments . " "; mail ('[email protected]', '[Website] '.$subject, $body, 'From: '.$email); echo '<h1>Thank-you!</h1><p>Your message was successfully sent,</p><p>If you had any questons we will try to respond ASAP.</p><br /></p>'; } else { return $errors; } furthur down the index.php page outside of the switch statement. <?php if(isset($errors)) displayErrors($errors); ?> but $errors isn't usable outside of the switch statement. how can i make it globally usable. i tried global $temp1, $temp1 = $errors but didn't work. TIA Quote Link to comment https://forums.phpfreaks.com/topic/124769-solved-make-array-usable-outside-switch-statement/ Share on other sites More sharing options...
ratcateme Posted September 18, 2008 Share Posted September 18, 2008 contactForm($_POST['name'], $_POST['email'], $_POST['phone'], $_POST['subject'], $_POST['comments']); should be $errors = contactForm($_POST['name'], $_POST['email'], $_POST['phone'], $_POST['subject'], $_POST['comments']); Scott. Quote Link to comment https://forums.phpfreaks.com/topic/124769-solved-make-array-usable-outside-switch-statement/#findComment-644530 Share on other sites More sharing options...
iarp Posted September 18, 2008 Author Share Posted September 18, 2008 very nice, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/124769-solved-make-array-usable-outside-switch-statement/#findComment-644535 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.