Jump to content

Using Varables across php pages


Amit_goyal

Recommended Posts

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>

 

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.