Below is the code which is supposed to redirect to a page once the whole form is filled up, the code works like a charm on my XAMPP server (localhost) , but as i uploaded my pages to my hosting area, the page stops redirecting, all it does is come back to the same page as if the page was refreshed !
Also,
i have included the script below to another page using <?php include 'filename.php'; ?>
Please Help!
code :
<form action="upload_images.php" method="post">
Name<span style="font-size: 10px"> </span>: <br/>
<input type="text" name="contact_name" maxlength="25"><br />
<p>Email Address<span style="font-size: 10px"> </span>:<br />
<input type="email" name="contact_email" maxlength="40">
<p>College :<br />
<input type="text" name="contact_college">
<br />
<br />
Tell us about your Photographs :<br />
<span style="font-size: 11px">(Optional)</span><br />
<textarea name="contact_text" cols="60" rows="10"></textarea>
<br>
<span style="font-size: 12px">All fields are mandatory </span>
<br>
<br>
<?php
error_reporting(0);
function full_copy( $source, $target ) {
if ( is_dir( $source ) ) {
@mkdir( $target );
$d = dir( $source );
while ( FALSE !== ( $entry = $d->read() ) ) {
if ( $entry == '.' || $entry == '..' ) {
continue;
}
$Entry = $source . '/' . $entry;
if ( is_dir( $Entry ) ) {
full_copy( $Entry, $target . '/' . $entry );
continue;
}
copy( $Entry, $target . '/' . $entry );
}
$d->close();
}else {
copy( $source, $target );
}
}
if (isset ($_POST['contact_name']) && isset ($_POST['contact_email']) && isset ($_POST['contact_text']))
{
$rand = rand(1,1000000000);
$contact_name = $rand.$_POST['contact_name'];
$contact_email = $_POST['contact_email'];
$contact_text = $_POST['contact_text'];
$contact_college = $_POST['contact_college'];
if (!empty($contact_name) && !empty($contact_email) && !empty($contact_college) )
{
$to = 'contact@pingcampus.com';
$submit = 'Contact Form Submitted';
$body = $contact_name."\n".$contact_college."\n".$contact_text;
$headers = 'From:'.$contact_email;
if(!is_dir("./uploads/".$contact_name))
{
mkdir("./uploads/".$contact_name, 0777, true); //if the directory doesn't exist then make it
chmod("./uploads/".$contact_name, 0777);
//copy('files','uploads/'.$contact_name.'/index.html');
$source= 'files';
$target = 'uploads/'.$contact_name;
full_copy($source,$target);
$variable = 'uploads/'.$contact_name.'/'.$contact_name.'.txt';
$handle = fopen("$variable",'w');
fwrite($handle, "<hr>".'<b>'.'<u>'.'Name:'.$contact_name.'</u>'.'</b>'.' says:'.'<font size="1" >'.'<br />'.'on '.date("l, F d, Y ").'</font>'."\n");
fwrite($handle,"<br />".'<!--'.$contact_email.'-->');
fwrite($handle,"<br />".'<!--'.$contact_text.'-->');
fwrite($handle, "<br />");
fclose($handle);
header("Location: uploads/$contact_name/index.html");
}
else
{
echo'OOPS! Guess there was an error! Please try again! ';
}
}
else
{
echo ' <h3>All Fields are Required!</h3>' ;
}
}
?>
<br>
<input type="submit" value="Proceed!">
<br>
<br>
</p>
<p>
<p>
<p>
<p>
<p>
<p>
<p>
<p>
<p>
<p>
<p>
</form>
</p>