Author Topic: Contact Page  (Read 4113 times)

Offline sdo1web

  • Jr. Member
  • *****
  • Posts: 11
  • Karma: +0/-0
Contact Page
« on: February 24, 2016, 05:58:25 PM »
phpEnter Web Hosting
I had created a contact page. Please I want somebody to tell how to put a contact form that will include php codes. Thanks

Offline alexa

  • Administrator
  • Full Member
  • *****
  • Posts: 255
  • Karma: +0/-0
Re: Contact Page
« Reply #1 on: February 24, 2016, 06:38:24 PM »
Try this:

Code: [Select]
<?php session_start();
include (
'settings.php');
require_once (
'languages/lang_'.$langs.'.php');
$arecordSet $conn->Execute('SELECT * FROM categori ORDER BY name ASC');
if (!
$arecordSet)
 print 
$conn->ErrorMsg();
else
 while (!
$arecordSet->EOF) {
  if (
$arecordSet->fields['cord'] == 0) {
   
$aval[] = $arecordSet->fields;
   }else{
   
$nval[] = $arecordSet->fields;
   }
   
$arecordSet->MoveNext();
}
$smarty->assign('categori',$aval);
$smarty->assign('subcat'$nval);
$smarty->display('blank.php');
?>


YOUR CODE HERE

<?php
echo"</div>";
$smarty->display('footer.php');
$conn->Close();
?>

Offline sdo1web

  • Jr. Member
  • *****
  • Posts: 11
  • Karma: +0/-0
Re: Contact Page
« Reply #2 on: February 25, 2016, 08:11:36 AM »
Try this:

Code: [Select]
<?php session_start();
include (
'settings.php');
require_once (
'languages/lang_'.$langs.'.php');
$arecordSet $conn->Execute('SELECT * FROM categori ORDER BY name ASC');
if (!
$arecordSet)
 print 
$conn->ErrorMsg();
else
 while (!
$arecordSet->EOF) {
  if (
$arecordSet->fields['cord'] == 0) {
   
$aval[] = $arecordSet->fields;
   }else{
   
$nval[] = $arecordSet->fields;
   }
   
$arecordSet->MoveNext();
}
$smarty->assign('categori',$aval);
$smarty->assign('subcat'$nval);
$smarty->display('blank.php');
?>


YOUR CODE HERE

<?php
echo"</div>";
$smarty->display('footer.php');
$conn->Close();
?>
Alexa. Thanks for your quick response. Where do I put the html form code?

Offline alexa

  • Administrator
  • Full Member
  • *****
  • Posts: 255
  • Karma: +0/-0
Re: Contact Page
« Reply #3 on: February 25, 2016, 08:25:55 AM »
Replace "YOUR CODE HERE" with you code

Offline DnE3$ t3A/\/\

  • Jr. Member
  • *****
  • Posts: 14
  • Karma: +0/-0
Re: Contact Page
« Reply #4 on: March 07, 2016, 01:27:00 PM »
Hello Alexa. Can you make for us a "Contact Us" form such as per attachment? we will be thankful to you.

Thank you.

Offline sdo1web

  • Jr. Member
  • *****
  • Posts: 11
  • Karma: +0/-0
Re: Contact Page
« Reply #5 on: April 11, 2016, 07:55:43 AM »
Try this:

Code: [Select]
<?php session_start();
include (
'settings.php');
require_once (
'languages/lang_'.$langs.'.php');
$arecordSet $conn->Execute('SELECT * FROM categori ORDER BY name ASC');
if (!
$arecordSet)
 print 
$conn->ErrorMsg();
else
 while (!
$arecordSet->EOF) {
  if (
$arecordSet->fields['cord'] == 0) {
   
$aval[] = $arecordSet->fields;
   }else{
   
$nval[] = $arecordSet->fields;
   }
   
$arecordSet->MoveNext();
}
$smarty->assign('categori',$aval);
$smarty->assign('subcat'$nval);
$smarty->display('blank.php');
?>


YOUR CODE HERE

<?php
echo"</div>";
$smarty->display('footer.php');
$conn->Close();
?>
Hi Alexa,
Sorry for being incommunicado for sometime. When I put 'MY CODE' as shown below. I always get a blank page. Plz help.
<?php session_start();
include ('settings.php');
require_once ('languages/lang_'.$langs.'.php');
$arecordSet = $conn->Execute('SELECT * FROM categori ORDER BY name ASC');
if (!$arecordSet)
 print $conn->ErrorMsg();
else
 while (!$arecordSet->EOF) {
  if ($arecordSet->fields['cord'] == 0) {
   $aval[] = $arecordSet->fields;
   }else{
   $nval[] = $arecordSet->fields;
   }
   $arecordSet->MoveNext();
}
$smarty->assign('categori',$aval);
$smarty->assign('subcat', $nval);
$smarty->display('blank.php');
?>
    <?php
if(isset($_POST['email'])) {
     
    // CHANGE THE TWO LINES BELOW
    $email_to = "stjohnsconiye@gmail.com";
     
    $email_subject = "Contact Form";
     
     
    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }
     
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['last_name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['telephone']) ||
        !isset($_POST['comments'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');     
    }
     
    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['telephone']; // not required
    $comments = $_POST['comments']; // required
     
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!preg_match($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.\n\n";
     
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }
     
    $email_message .= "First Name: ".clean_string($first_name)."\n";
    $email_message .= "Last Name: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Telephone: ".clean_string($telephone)."\n";
    $email_message .= "Comments: ".clean_string($comments)."\n";
     
     
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);

echo"Thank you for contacting us. We will be in touch with you very soon.";
?>
<?php
}
die();
?>
>
                   <h2>Contact Form</h2>
                    <h3>Use the form below to contact us. The * fields are required.</h3>
                    </br></br>
                    <p><form name="htmlform" method="post" action=" ">
<table width="450px">
</tr>
<tr>
 <td valign="top">
  <label for="first_name"><b>First Name *</b></label>
 </td>
 <td valign="top">
  <input  type="text" name="first_name" maxlength="50" size="30">
 </td>
</tr>
 
<tr>
 <td valign="top"">
  <label for="last_name"><b>Last Name *</b></label>
 </td>
 <td valign="top">
  <input  type="text" name="last_name" maxlength="50" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="email"><b>Email Address *</b></label>
 </td>
 <td valign="top">
  <input  type="text" name="email" maxlength="80" size="30">
 </td>
 
</tr>
<tr>
 <td valign="top">
  <label for="telephone"><b>Telephone Number</b></label>
 </td>
 <td valign="top">
  <input  type="text" name="telephone" maxlength="30" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="comments"><b>Comments *</b></label>
 </td>
 <td valign="top">
  <textarea  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
 </td>
 
</tr>
<tr>
 <td colspan="2" style="text-align:center">
  <input type="submit" value="Submit">   
 </td>
</tr>
</table>
</form></p></div>

<?php
echo"</div>";
$smarty->display('footer.php');
$conn->Close();
?>

Offline sdo1web

  • Jr. Member
  • *****
  • Posts: 11
  • Karma: +0/-0
Re: Contact Page
« Reply #6 on: July 15, 2016, 12:22:30 PM »
Hi,
Anytime I want to embed PHP code in any of my page as shown in previous post had always resulted in a blank. If I remove the PHP code the page will display the contact form. I used these {php} and {/php} tags instead of <?php and ?> tags, the page will show the whole PHP code with the form. Can the code be included as a plugin? If yes, How can I create a plugin and integrate it into a page? Can somebody help me out?
« Last Edit: July 15, 2016, 02:48:37 PM by sdo1web »

Offline goli

  • Full Member
  • *****
  • Posts: 40
  • Karma: +2/-0
Re: Contact Page
« Reply #7 on: July 16, 2016, 12:52:45 PM »
{php} {/php} tags are deprecated from Smarty:

http://www.smarty.net/docs/en/language.function.php.tpl