Amit_goyal Posted August 25, 2014 Share Posted August 25, 2014 I want to use my form variables in other page which is not specified in action attribute. Please help me out !!! My code is below : <body> <?php require("common.php");?> <h1> <?php echo(COMPANY); ?> Job Application </h1> <p> Are you looking for an exciting career in the world of cyclery ? Look no further ! </p> <form name="frmJobApp" method="post" enctype="multipart/form-data" action="jobapp action.php"> Please enter Your Name (<i>required</i>): <input name="applicant" type="text" /><br /> Please enter your telephone number : <input type="text" name="phone" /><br /> Please enter your full mailing address :<br /> <textarea name="addr" rows="5" cols="40" wrap="soft"></textarea><br /> Please enter your email address (<i>required</i>): <input type="text" name="email" /><br /> Please select the type of position in which you are interested : <select name="position"> <option value="a"> Accounting </option> <option value="b"> Bicycle repair </option> <option value="h"> Human Resources </option> <option value="m"> Management </option> <option value="s"> Sales </option> </select><br /> Please select the name of the country in which you would like to work : <select name="country"> <option value="cn">Canada </option> <option value="cr">Costa Rica </option> <option value="ge">Germany</option> <option value="uk">United Kingdom</option> <option value="us">United States</option> </select><br /> Please Upload your resume : <input type="hidden" name="max_file_size" value="10000" /> <input type="file" name="userfile" /><br /> <input name="avail" type="checkbox" /> Available Immediately<br /> <input name="enter" type="submit" value="Enter" /> </form> </body> </html> I WANT TO USE THE VARIABLE "$applicant" FROM ABOVE FORM TO USE IN THE BELOW GIVEN SCRIPT ....I m not able to pass the value of $applicant from the form page to this page...PLS TELL ME HOW TO <body> <?php chdir("/applicants"); $dir="./$applicant"; $count=0; while(is_dir($dir)) { $count++; $dir=$_SESSION['applicant'].$count; } mkdir($dir,0700); copy("/temp/$applicant", $dir . "/resume.txt"); unlink("/temp/$applicant"); $to="hr@phop'sbicycles.com"; $subj="Online Application"; $header="\nFrom: jobapp@taurix.com\n"; $body="\n Name:".quotemeta($applicant) ; $success=mail($to,$subj,$body,$header); $textfile=fopen($dir."/details.txt","w"); fwrite($textfile,$body); fclose($textfile); if($success) { echo("Your application has been sent successfully"); } else { echo("Error sending Application"); } ?> </body> </html> </body> Quote Link to comment https://forums.phpfreaks.com/topic/290643-using-varables-across-php-pages/ Share on other sites More sharing options...
mogosselin Posted August 25, 2014 Share Posted August 25, 2014 You could set your $applicant into the session using $_SESSION['applicant'] = $applicant. And then, to retrieve it in your other script: $applicant = $_SESSION['applicant']; Note that you need to use session_start() before using the $_SESSION variable. session_start() info: http://php.net/manual/en/function.session-start.php $_SESSION info: http://php.net/manual/en/reserved.variables.session.php Note that you can use the 'code' button when you write your post to include code. It will be easier to look at it that this way Quote Link to comment https://forums.phpfreaks.com/topic/290643-using-varables-across-php-pages/#findComment-1488890 Share on other sites More sharing options...
ginerjm Posted August 25, 2014 Share Posted August 25, 2014 As Mogosselin says - you can use the $_SESSION array. Which you are already using as I see "$_SESSION['applicant'] already in use in your code!!! Quote Link to comment https://forums.phpfreaks.com/topic/290643-using-varables-across-php-pages/#findComment-1488891 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.