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 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. 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. 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
Archived
This topic is now archived and is closed to further replies.