PHP pagina maken

Dit forum is bedoeld voor vragen met betrekking tot WYSIWYG Web Builder.
Post Reply
NicoZ
 
 
Posts: 2
Joined: Sun Aug 13, 2017 10:10 pm

PHP pagina maken

Post by NicoZ » Mon Aug 14, 2017 2:40 pm

Ik wil een contactpagina maken voor mijn website in PHP.
Wat ik ook probeer de pagina laadt niet. Als ik mijn website upload en naar de contactpagina wil gaan krijg ik een Internal Server Error.

Wie o wie kan mij helpen :|

User avatar
Pablo
 
Posts: 19615
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: PHP pagina maken

Post by Pablo » Mon Aug 14, 2017 3:45 pm

Als ik mijn website upload en naar de contactpagina wil gaan krijg ik een Internal Server Error.
Dit betekent waarschijnlijk dat er bestanden ontbreken of een fout in de instellingen. Maar het kan ook een server configuratie fout zijn.
Heb je alle bestanden geupload?
Wat zijn je exacte instellingen?
Wat is de genereerde PHP code?

NicoZ
 
 
Posts: 2
Joined: Sun Aug 13, 2017 10:10 pm

Re: PHP pagina maken

Post by NicoZ » Tue Aug 15, 2017 9:10 pm

de code is gemaakt met wysiwyg

<?php
require 'phpmailerautoload.php';
function ValidateEmail($email)
{
$pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
return preg_match($pattern, $email);
}
function RecursiveMkdir($path)
{
if (!file_exists($path))
{
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['formid']) && $_POST['formid'] == 'form1')
{
$mailto = 'your@mail.nl';
$mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
$subject = 'Website form';
$message = 'Values submitted from web site form:';
$success_url = './Templates.html';
$error_url = './page2.html';
$error = '';
$eol = "\n";
$max_filesize = 10000*1024;
$upload_folder = "public_html/upload";
$upload_folder = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])."/".$upload_folder;

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'mail.gezonderenbeterl.nl ';
$mail->Port = 465;
$mail->SMTPAuth = false;
$mail->Subject = stripslashes($subject);
$mail->From = $mailfrom;
$mail->FromName = $mailfrom;
$mailto_array = explode(",", $mailto);
for ($i = 0; $i < count($mailto_array); $i++)
{
if(trim($mailto_array[$i]) != "")
{
$mail->AddAddress($mailto_array[$i], "");
}
}
$mail->AddReplyTo($mailfrom);
if (!ValidateEmail($mailfrom))
{
$error .= "The specified email address is invalid!\n<br>";
}

$prefix = rand(111111, 999999);

$i = 0;
while (list ($key, $val) = each ($_FILES))
{
if ($_FILES[$key]['name'] != "" and file_exists($_FILES[$key]['tmp_name']) and $_FILES[$key]['size'] > 0)
{
$upload_DstName[$i] = $prefix . "_" . str_replace(" ", "_", $_FILES[$key]['name']);
$upload_SrcName[$i] = $_FILES[$key]['name'];
$upload_Size[$i] = ($_FILES[$key]['size']);
$upload_Temp[$i] = ($_FILES[$key]['tmp_name']);
$upload_URL[$i] = "$upload_folder/$upload_DstName[$i]";
$upload_FieldName[$i] = $key;
}
if ($upload_Size[$i] >= $max_filesize)
{
$error .= "The size of $key (file: $upload_SrcName[$i]) is bigger than the allowed " . $max_filesize/1024 . " Kbytes!\n";
}
$i++;
}

if (!empty($error))
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $error, $errorcode);
echo $errorcode;
exit;
}

$uploadfolder = basename($upload_folder);
for ($i = 0; $i < count($upload_DstName); $i++)
{
$uploadFile = $uploadfolder . "/" . $upload_DstName[$i];
if (!is_dir(dirname($uploadFile)))
{
RecursiveMkdir(dirname($uploadFile));
}
move_uploaded_file($upload_Temp[$i] , $uploadFile);
chmod($uploadFile, 0644);
$name = "$" . $upload_FieldName[$i];
$message = str_replace($name, $upload_URL[$i], $message);
}

$internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field", "g-recaptcha-response");
$message .= $eol;
$message .= "IP Address : ";
$message .= $_SERVER['REMOTE_ADDR'];
$message .= $eol;
$logdata = '';
foreach ($_POST as $key => $value)
{
if (!in_array(strtolower($key), $internalfields))
{
if (!is_array($value))
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
}
else
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
}
}
}
if (count($upload_SrcName) > 0)
{
$message .= "\nThe following files have been uploaded:\n";
for ($i = 0; $i < count($upload_SrcName); $i++)
{
$message .= $upload_SrcName[$i] . ": " . $upload_URL[$i] . "\n";
}
}
$mail->CharSet = 'UTF-8';
$mail->WordWrap = 80;
$mail->Body = $message;
if (!$mail->Send())
{
die('PHPMailer error: ' . $mail->ErrorInfo);
}
header('Location: '.$success_url);
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="nl"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>contactformulier</title>
<meta name="generator" content="WYSIWYG Web Builder 12 Trial Version - http://www.wysiwygwebbuilder.com"/>
<link href="Untitled1_-_kopie.css" rel="stylesheet" type="text/css"/>
<link href="contact.css" rel="stylesheet" type="text/css"/>
<!-- Insert Google Analytics code here -->
</head>
<body>
<div id="container">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="trans.gif" width="10" height="194"/></td>
<td><img src="trans.gif" width="140" height="1"/></td>
<td><img src="trans.gif" width="980" height="1"/></td>
</tr>
<tr><td><img src="trans.gif" width="1" height="359"/></td>
<td/>
<td align="left" valign="top" rowspan="2">
<table align="left" valign="top" border="0" cellspacing="0" cellpadding="0" width="980" height="721">
<tr>
<td align="left" valign="top">
<div id="wb_Form1" style="position:absolute;width:970px;height:711px;">
<form name="Contact" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" accept-charset="UTF-8" target="_self" id="Form1">
<input type="hidden" name="formid" value="form1"/>
<label for="Editbox1" id="Label1" style="position:absolute;left:10px;top:28px;width:52px;height:19px;line-height:19px;z-index:9;" tabindex="1">Naam:</label>
<input type="text" id="Editbox1" class="CustomStyle" style="position:absolute;left:145px;top:28px;width:392px;height:19px;line-height:19px;z-index:10;" name="Naam" value="" tabindex="2" spellcheck="false"/>
<label for="Editbox2" id="Label2" style="position:absolute;left:10px;top:69px;width:117px;height:19px;line-height:19px;z-index:11;" tabindex="3">Email:</label>
<input type="text" id="Editbox2" class="CustomStyle" style="position:absolute;left:145px;top:69px;width:392px;height:19px;line-height:19px;z-index:12;" name="E-mail" value="" tabindex="4" spellcheck="false"/>
<label for="Editbox3" id="Label3" style="position:absolute;left:10px;top:110px;width:117px;height:19px;line-height:19px;z-index:13;" tabindex="5">Telefoon:</label>
<input type="text" id="Editbox3" class="CustomStyle" style="position:absolute;left:145px;top:110px;width:392px;height:19px;line-height:19px;z-index:14;" name="Telefoon" value="" tabindex="6" spellcheck="false"/>
<label for="TextArea1" id="Label4" style="position:absolute;left:10px;top:159px;width:117px;height:19px;line-height:19px;z-index:15;" tabindex="7">Bericht:</label>
<textarea name="Bericht" id="TextArea1" class="CustomStyle" style="position:absolute;left:145px;top:159px;width:769px;height:417px;z-index:16;" rows="20" cols="93" tabindex="8" spellcheck="false"></textarea>
<input type="submit" id="Button1" name="" value="versturen" style="position:absolute;left:145px;top:648px;width:783px;height:38px;z-index:17;" tabindex="11"/>
</form>
</div>
</td>
</tr></table></td>
</tr>
<tr><td><img src="trans.gif" width="1" height="362"/></td>
<td align="left" valign="top">
<table align="left" valign="top" border="0" cellspacing="0" cellpadding="0" width="88" height="31">
<tr>
<td align="left" valign="top">
<a href="http://www.wysiwygwebbuilder.com" target="_blank"><img src="images/builtwithwwb12.png" alt="WYSIWYG Web Builder" style="position:absolute;border-width:0;z-index:250"/></a>
</td>
</tr></table></td>
</tr>
</table>
</div>
</body>
</html>

User avatar
Pablo
 
Posts: 19615
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: PHP pagina maken

Post by Pablo » Wed Aug 16, 2017 5:38 am

Alles lijkt te kloppen, alleen twijfel ik of de upload folder correct is: 'public_html/upload', ik denk dat dit 'upload' moet zijn.
Ik zie ook dat de phpmailer gebruikt, dus in dat geval moeten alle phpmailer bestanden ook geupload worden.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests