Browse Source

Fix contact form

leosw 8 months ago
parent
commit
91fa18f78c
2 changed files with 13 additions and 13 deletions
  1. 10 10
      controllers/d.contact.php
  2. 3 3
      views/d.contact.html

+ 10 - 10
controllers/d.contact.php

@@ -11,8 +11,8 @@ if(isset($_POST['submit'])) {
 	$message .= "<hr>\r\n";
 	$message .= "<pre style='padding: 10px; background: #ccc;'>".strip_tags(post('message'))."</pre><br>\r\n";
 
-	$headers = 'From: '. post('mail') . "\r\n" .
-	'Reply-To: '. post('mail') . "\r\n" .
+	$headers = 'From: '. post('email') . "\r\n" .
+	'Reply-To: '. post('email') . "\r\n" .
 	'X-Mailer: PHP/' . phpversion() . "\r\n" .
 	'MIME-Version: 1.0' . "\r\n" .
 	'Content-type: text/html; charset=UTF-8' . "\r\n"; 
@@ -27,8 +27,8 @@ if(isset($_POST['submit'])) {
 			$error = "subject";
 			$send = false;
 		}
-		if(post('mail') == '') {
-			$error = "mail";
+		if(post('email') == '') {
+			$error = "email";
 			$send = false;
 		}
 		if(post('message') == '') {
@@ -50,17 +50,17 @@ if(isset($_POST['submit'])) {
 
 if(post('name') != '')
 	$contact['name'] = post('name');
-else if($user->role > 0)
+else if($user->rankIsHigher("registered"))
 	$contact['name'] = $user->name;
 else
 	$contact['name'] = '';
 
-if(post('mail') != '')
-	$contact['mail'] = post('mail');
-else if($user->role > 0)
-	$contact['mail'] = $user->mail;
+if(post('email') != '')
+	$contact['email'] = post('email');
+else if($user->rankIsHigher("registered"))
+	$contact['email'] = $user->email;
 else
-	$contact['mail'] = '';
+	$contact['email'] = '';
 
 $contact['subject'] = post('subject');
 $contact['message'] = post('message');

+ 3 - 3
views/d.contact.html

@@ -16,7 +16,7 @@
 				<? if($error=="subject") { ?>
 					<p style="color: red;">Veuillez renseigner un sujet.</p>
 				<? } ?>
-				<? if($error=="mail") { ?>
+				<? if($error=="email") { ?>
 					<p style="color: red;">Veuillez renseigner une adresse mail.</p>
 				<? } ?>
 				<? if($error=="message") { ?>
@@ -33,10 +33,10 @@
 					<p style="color: green;">Message bien envoyé.</p>
 				<? } ?>
 				<input type="text" name="name" id="name" placeholder="Nom" value="<?=$contact['name']?>">
-				<input type="text" name="mail" id="mail" placeholder="Adresse mail" value="<?=$contact['mail']?>">
+				<input type="text" name="email" id="email" placeholder="Adresse mail" value="<?=$contact['email']?>">
 				<input type="text" name="subject" id="subject" placeholder="Sujet" value="<?=$contact['subject']?>">
 				<textarea name="message" id="message" rows="12" placeholder="Contenu de votre message"><?=$contact['message']?></textarea>
-				<? if($user->role >= 200) { ?>
+				<? if($user->rankIsHigher("registered")) { ?>
 					<input type="hidden" name="captcha" value="-2">
 					<input type="submit" name="submit" value="Envoyer">
 				<? }