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: [email protected]\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
https://forums.phpfreaks.com/topic/290643-using-varables-across-php-pages/
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 ;)

Archived

This topic is now archived and is closed to further replies.

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