1.

Solve : Page Title?

Answer»

I'm creating my own website from scratch and use the "unlimited space" on cwahi.

So far I've gotten the initial index.html plus a contact form and thank you page.

The only problem I'm having at the moment is creating some sort of custom page title for the contact form.

That wouldn't be a problem if I had it as an html file.

I've got it as a php.

With html I know that the code would read as <title>Chris's Corner</title>.

But since this is php I've got no idea and not having much luck finding any articles anywhere on how to do this beside using the header (Don't understand how this is suppose to happen.)

If anyone out there can point me in the right direction or give some advice, I really would appreciate it.



TYIAYou can write normal HTML code in a PHP file.  It should display normally.  PHP just brings some extra features.  Anything between the TAGS are PHP code.  If you don't use those tags, it will just act like normal HTML.

That said, if you strip out the PHP, it may be that the contact form will not function correctly any more.  In short, you may need to learn PHP to understand what's going on.Just speaking hypothetically, if i were to include the tag I mentioned above before the initial php code it would display the text that I insert right? Quote from: DallasHack on October 30, 2012, 10:24:27 AM

Just speaking hypothetically, if i were to include the tag I mentioned above before the initial php code it would display the text that I insert right?
The code would be there, yes, but the browser probably wouldn't interpret it properly, or you might have duplicate title tags. The title tag has a specific location (the head section) which may be in another php file somewhere (using the include() or require() directives in php)

What is the output of the contact page when you view it in a browser? It should include a title somewhere. You can search your php files (good text editors or IDEs have a 'find in files' function) for a title tag or the current contact page title and see what you would have to do to CHANGE it. Because every website or CMS is configured a bit differently, you might have an administration tool to make edits in, some other file that holds information about the pages in your site, etc. etc.

If you don't see a title tag in your contact page's file, you need to find where the code actually resides and change it there.This is the code from the contact.php:

Code: [Select]<?php

session_start();
//Email Validation
function checkEmail($email) 
{
   if(eregi("^[a-zA-Z0-9_][email protected][a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) 
   {
          return FALSE;
   }

   list($Username, $Domain) = split("",$email);

   if(getmxrr($Domain, $MXHost)) 
   {
          return TRUE;
   }
   else 
   {
          if(fsockopen($Domain, 25, $ERRNO, $errstr, 30)) 
          {
                 return TRUE; 
          }
          else 
          {
                 return FALSE; 
          }
   }
}


// get posted data into local variables
$EmailTo = "fake [email protected]"; 
$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
$Name = Trim(stripslashes($_POST['Name'])); 
$Subject = Trim(stripslashes($_POST['Subject'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
$validationOK=true;
if(checkEmail($EmailFrom) == FALSE){
$error_msg[] = "Please enter in a valid email address.";
}
if (Trim($Name)==""){
$error_msg[] = "Please enter in a name.";
}
if (Trim($Subject)=="") {
$error_msg[] = "Please enter in a subject.";
}
if (Trim($Message)==""){
$error_msg[] = "Please enter in a message.";
}
//triggers error message
if ($error_msg) {
$_SESSION['error_msg'] = $error_msg;
header ('Location: index.php');
exit();
}
//sends email
else {
$Body = "You have a new email from $Name.\n\n Reply to $EmailFrom.\n\n $Name says,\n $Message";
$success = mail($EmailTo, $Subject, $Body);
}
//redirect to success page
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=ThankYou.html\">";
}
else{
  print "Email could not be sent due to errors. Please email the <a href='mailto:[email protected]>Webmaster</a>.";
}
?>


And as far as the page title for this it shows the url:

Code: [Select]http://b455hunt3r.cwahi.net/index.phpAdd a title tag to your index.php somewhere.

As a side note, none of this code looks valid (contact.php and index.php certainly aren't, anyway) because it LACKS the html, head, and body tags. You may want to look into adding these.I just looked at the stuff and that code is what is suppose to verify and send to my email.


This is the correct code for the form:

Code: [Select]<?php session_start(); ?>
<!--Start error code-->
<?php
if ($_SESSION['error_msg']) {
foreach ($_SESSION['error_msg'] as $val) {
echo "$val<br />";
}
unset($_SESSION['error_msg']);
}
?>
<!--End Error Code-->

<!--Start Form Code-->
                               
<form method="POST" action="contact.php">
                                                               
<p><label for="Name">Name</label><br />
<input id="Name" name="Name" type="text" tabindex="1" size="30" /></p>
                               
<p><label for="EmailFrom">Email</label><br />
<input id="EmailFrom" name="EmailFrom" type="text" tabindex="2" size="30" /></p>
                               
<p><label for="Subject">Subject</label><br />
<input id="Subject" name="Subject" type="text" tabindex="3" size="30" /></p>
                                                       
<p><label for="words">Message</label><br />
<textarea name="Message" tabindex="5" rows="10" cols="24" style="width:300px;"></textarea></p>
                               
<input type="submit" name="post" id="post" value=" Send " />  <input type="reset" value=" Reset " />
</form>
<!--End Form Code-->And not to bump this thread but thanks for taking a moment to reply.I figured out what to do.

All I had to do was take the homepage code and past the contact form code inside the body section and I changed the title in the section where it was located.

Thanks for the help though guys.



Discussion

No Comment Found