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 :
[php]
Name :Email Address :
College :
Tell us about your Photographs :
(Optional)
All fields are mandatory
<?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 = '[email protected]';
$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>' ;
}
}
?>
[/php]