Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on Creating a Right-To-Left, primarily-backend, HTML-PHP contact form
Post
Creating a Right-To-Left, primarily-backend, HTML-PHP contact form
I host my website on a PaaS-modeled, shared hosting environment by SiteGround which is quite a well known hosting company with (as I believe) well-venerated email servers.
I am trying to create an RTL-first primarily backend HTML-PHP contact form.
If I use the following code I can submit the form and there is no error In the browser or in an autogenerated error log file but I also don't get an email.
What might be a problem in my latest code version below?
HTML
<!DOCTYPE html>
<html>
<head>
<title>יצירת קשר</title>
<meta charset="utf-8">
<link rel="stylesheet" href="./0_contact_form.css" type="text/css"></link>
<!-- Normally scripts comes under the <body> tag but for a contact form file here is also fine -->
</head>
<body>
<form dir="rtl" lang="he" method="POST" action="./0_contact_form.php" onsubmit="return redirectMe();" id="contact_form">
<h2>יצירת קשר</h2>
<p><label for="name" class="required">שם</label><input type="text" name="name" required id="cf_name"></input></p>
<p><label for="email" class="required">כתובת אימייל</label><input type="email" name="email" required id="cf_email"></input></p>
<p><label for="phone">מספר טלפון </label><input type="tel" name="phone" id="cf_phone"></input></p>
<!-- SPECIFICALLY ADDED WHITESPACE TO מספר טלפון -->
<p><label for="topic">פנייה בנושא</label> <select name="topic" id="cf_topic">
<option value="אבחון קידום אתרים (כמפורט במחירון)">אבחון קידום אתרים (כמפורט במחירון)</option>
<option value="שיווק באמצעות תוכן (כמפורט במחירון)">שיווק באמצעות תוכן (כמפורט במחירון)</option>
<option value="פיתוח קישורים (כמפורט במחירון)">פיתוח קישורים (כמפורט במחירון)</option>
<option value="ייעוץ והדרכה (כמפורט במחירון)">ייעוץ והדרכה (כמפורט במחירון)</option>
<option value="נגישות">נגישות</option>
</select></p>
<label for="date">תאריך רצוי לפגישה (אם יש)</label> <input type="date" name="date" id="cf_date">
<p><label for="notes">הערות (אם יש)</label> <input name="notes" type="text" id="cf_notes"/></p>
<p><input type="submit" value="שליחה"></input></p>
</form>
</body>
</html>
CSS
.required:after {content:"* "; color: red;}
PHP
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$topic = $_POST["topic"];
$date = $_POST["date"];
$notes = $_POST["notes"];
$to = "EMAIL_ADDRESS@EMAIL_TLD";
$subject = "הודעת יצירת קשר";
$message = array (
$name . "שם" . "\r\n",
$email . "אימייל" . "\r\n",
$phone . "טלפון" . "\r\n",
$topic . "פנייה בנושא" . "\r\n",
$date . "תאריך רצוי לפגישה (אם יש)" . "\r\n",
$notes . "הערות (אם יש)" . "\r\n"
);
$headers = array(
"From" => $email,
"Reply-To" => $email,
"X-Mailer: PHP/" . phpversion()
);
# The order should be as above: $to, $subject, $message and $headers
mail($to, $subject, $message, $headers);
?>
1 comment thread