Jump to content
Killersites Forums

I got this codes inside our very own Killersites.com


Don Ross 76
 Share

Recommended Posts

Hello,

 

I built a contact page on my website using the codes I have learn here at Killersites.com Video tutorial Library,

 

I have use an SEO tool for my website and it told me there is a broken internal link inside the code, I can't find it. Please help me where is this broken internal link.

 

Any help or suggestion is appreciated.

 

Anyway I have replaced my website address to www.mywebsite.com for privacy reason and also my email address was changed. My website is working fine and I can actually send message and received it, but in the codes the SEO tool detected a broken link. This is very easy for experience programmer.

 

Thanks for the reply in advance.

 

Kind regards,

 

Don76

 

Here is the code:

 

 

<?php

 

// variables

$to = 'support@mywebsite.com';

$subject = "Message from your website mywebsite.com";

 

$error_open = "<label class='error'>";

$error_close = "</label>";

$valid_form = TRUE;

$redirect = "success.php";

 

$form_elements = array('name', 'email', 'message');

$required = array('name', 'email', 'message');

 

foreach ($required as $require)

{

$error[$require] = '';

}

 

if (isset($_POST['submit']))

{

// process form

 

// get form data

foreach ($form_elements as $element)

{

$form[$element] = htmlspecialchars($_POST[$element]);

}

 

// check form elements

// check required fields

if ($form['name'] == '')

{

$error['name'] = $error_open . "Please fill in all required fields!" . $error_close;

$valid_form = FALSE;

}

 

if ($form['email'] == '')

{

$error['email'] = $error_open . "Please fill in all required fields!" . $error_close;

$valid_form = FALSE;

}

if ($form['message'] == '')

{

$error['message'] = $error_open . "Please fill in all required fields!" . $error_close;

$valid_form = FALSE;

}

 

// check formatting

 

 

if ($error['email'] == '' && !preg_match('/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/', $form['email']))

{

$error['email'] = $error_open . "Please enter a valid email!" . $error_close;

$valid_form = FALSE;

}

 

// check for bad data

if (contains_bad_str($form['name']) ||

contains_bad_str($form['email']) ||

contains_bad_str($form['message']))

{

$valid_form = FALSE;

}

if (contains_newlines($form['name']) ||

contains_newlines($form['email']))

 

{

$valid_form = FALSE;

}

 

// check if form is valid

if ($valid_form)

{

// create message

$message = "Name: " . $form['name'] . "\n";

$message .= "Email: " . $form['email'] . "\n";

$message .= "Message: " . $form['message'];

 

$headers = "From: www.mywebsite.com <support@mywebsite.com>\r\n";

$headers .= "X-Sender: <support@mywebsite.com>\r\n";

$headers .= "X-Mailer: PHP/". phpversion() ."\r\n";

$headers .= "Reply-To: " . $form['email'];

 

// send email

mail($to, $subject, $message, $headers);

 

// redirect

header("Location: " . $redirect);

}

else

{

include('contactus.php');

}

 

}

else

{

foreach ($form_elements as $element)

{

$form[$element] = '';

}

 

// display form

include('contactus.php');

}

 

 

 

function contains_bad_str($str_to_test) {

$bad_strings = array(

"content-type:",

"mime-version:",

"multipart/mixed",

"Content-Transfer-Encoding:",

"bcc:",

"cc:",

"to:");

 

foreach($bad_strings as $bad_string) {

if(stristr(strtolower($str_to_test), $bad_string)) {

return true;

}

}

return false;

}

 

function contains_newlines($str_to_test) {

if(preg_match("/(%0A|%0D|\\n+|\\r+)/i", $str_to_test) != 0) {

return true;

}

return false;

}

 

?>

Link to comment
Share on other sites

I don't do PHP, but -unless there's a coding mistake- we wouldn't know what internal link was broken.

 

User the W3C Link Checker - http://validator.w3.org/checklink - I believe that will tell you which link is broken.

 

Thank you very much for that Link Checker didn't know it exist. I tried it but the robot.txt is blocking it.

 

Thanks again. Hopefully someone who knows PHP can see the code above. It was taught here at killersites.com but I'm a beginner I must have missed it.

 

Kind regards,

 

Don

Link to comment
Share on other sites

hello,

 

I can do that what I'm thinking and I think what the SEO tool is telling is that there is a broken link inside the PHP code.

 

I'm not an adept PHP programmer so I really can't see where that code is broken, but I think I can find that out by the help of you Link checker from W3C you just gave me. I just have to rewrite the robot.txt so that the link checker can crawl it and find out.

 

Thanks Andrea for the help I really appreciate.

 

Kind regards,

 

Don

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...