Ich habe ein Formular, das eine E-Mail mit einer Bestellnummer sendet Ich möchte den Benutzer auf eine Dankeseite übertragen und eine Nachricht anzeigen "" Mail gesendet Vielen Dank Vorname wir kontaktieren Sie kurz Ihre Bestellnummer:“send_email.php dies die E-Mail sendet und überträgt den Benutzer auf die Seite Sie danken: Erstens habe ich einige Fehler zu überprüfen, ob es keine Fehler gibt ich die E-Mail-php - Header ('Ort') mit Nachricht
<?php
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$nameErr = $lastNameErr = $emailErr = $ironingErr = $descriptionErr = $RoomErr = NULL;
$first_name = $last_name = $email = $ironing = $description = $Rooms ="";
if(isset($_POST['submit'])){
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$ironing = $_POST['ironing'];
$Rooms = $_POST['Rooms'];
$Hours = $_POST['Hours'];
$Description = $_POST['description'];
// If email injection is detected, redirect to the error page.
if (isInjected($from)) {
header("Location: $error_page");
}
if (empty($_POST["first_name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["first_name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$emailErr = "Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
if (empty($_POST["description"])) {
$descriptionErr = "Description is required";
} else {
$description = test_input($_POST["description"]);
}
if (empty($_POST["Rooms"])) {
$RoomErr = "Room number is Required";
} else {
$Rooms = test_input($_POST["Rooms"]);
}
if (empty($_POST["Hours"])) {
$HourErr = "Room number is Required";
} else {
$Hours = test_input($_POST["Rooms"]);
}
if ($_POST["Hours"] < 3) {
$RoomErr = "Mininum number of Hours : 3";
} else {
$Rooms = test_input($_POST["Rooms"]);
}
if (empty($_POST["ironing"])) {
$ironingErr = "Ironing is Required";
} else{
$ironing = test_input($_POST["ironing"]);
}
if (isset($nameErr) || isset($lastNameErr) || isset($emailErr) ||
isset($ironingErr) || isset($descriptionErr) || isset($RoomErr)) {
// You have an error
} else {
$today = date("Ymd");
$rand = strtoupper(substr(uniqid(sha1(time())),0,4));
$unique = $today . $rand;
$to = "someemail.com"; // this is your Email address
$subject = "Order Sumbittion: " . $unique;
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['description']. "\n\n" . "Number of Rooms: ". $_POST['Rooms'] . "\n\n" ."Number of Hours : ".$_POST['Hours'] . "\n\n" ."Ironing: " . $_POST['ironing'];
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['description']. "\n\n" . "Number of Rooms: " . $_POST['Rooms']. "\n\n" . "Number of Hours : " . $_POST['Hours'] . "\n\n" ."Ironing: ". $_POST['ironing'] ."\n\n"."Your Odred Number = ". $unique . "\n\n". "Thank you for your Order our Team will be in contact with you shortly."."\n\n". "Check Our facebook page at facebook.com/GlossyCleaningService" ;
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2);
// sends a copy of the message to the sender
header("Location:thank_you.php?first_name={$first_name}");
exit;
}
}
?>
auf meinem thank_you senden .php Seite Ich habe das folgende PHP-Skript
<?php
include ('send_mail.php');
if(isset($_GET['first_name'])) {
echo "Mail Sent. Thank you " . $_GET['first_name'] . ", we will contact you shortly.";
}
?>
Die Nachricht, die ich auf meinem bekommen Webseite ist
„Hinweis: undefinierte Variable: einzigartig in /storage/ssd1/717/1954717/public_html/thank_you.php on line 126 Mail. Vielen Dank, wir werden Sie in Kürze kontaktieren, Ihre Bestellnummer:. "
Die Webseite doesnt Druck der Vorname oder der Bestellnummer es scheint, wie es es nicht finden können
UPDATE:. Ich änderte meine Code Kevin Nelson Antwort ich nicht einen Fehler erhalten oder die Nachricht einfach leer
Check das Problem hier:.. mysite
Versuchen Sie die Auftrags-ID in der Sitzung zu speichern? Mit Kopfzeile ('Ort ...'); Sie leiten den Benutzer um, und die Variable ist verloren –
Es gibt keine Variable '$ first_name' in der Datei' send_mail.php', es sei denn, Sie haben uns nicht alles gezeigt. – TripleDeal
Wenn Sie keine Session verwenden und die Order ID nicht versteckt werden soll, können Sie sie über die URL in einem GET var: 'header ('Ort: thank_you.php? Unique ='. $ Unique);' – Kaddath