Web Design Forum: PHP contact form XHTML strict - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

PHP contact form XHTML strict Rate Topic: ***** 1 Votes

#41 User is offline   mrchristoph 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,231
  • Joined: 18-August 09
  • Reputation: 76

Posted 06 October 2009 - 11:54 AM

Ok thanks I'll try this tonight. Also I need to change the 'website url' to telephone number, so need to know which parts of the php script need changing accordingly - I'm sure I can figure it out myself eventually though! PHP is on my list of things to learn, but now I'm simply copying the ocde and hope it works :)
0

#42 User is offline   Jem 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 288
  • Joined: 20-April 08
  • Reputation: 1
  • Gender:Female
  • Location:Telford, Shrops.
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 06 October 2009 - 01:20 PM

You won't see PHP when you view source because it's parsed before it reaches the browser - that means that PHP is doing its job :)

I've just had a look at your contact.php and it still says mail_form_v2.php in the form:
<form action="mail_form_v2.php" method="post">


This needs changing to:
<form action="contact.php" method="post">

0

#43 User is offline   mrchristoph 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,231
  • Joined: 18-August 09
  • Reputation: 76

Posted 06 October 2009 - 01:26 PM

So i don't need a separate php file then, as long as I amend the "form action" part? Cool thanks.
0

#44 User is offline   Jem 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 288
  • Joined: 20-April 08
  • Reputation: 1
  • Gender:Female
  • Location:Telford, Shrops.
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 06 October 2009 - 03:02 PM

You seem to have already put the code into contact.php? As long as I have that right, it will work from there :)
0

#45 User is offline   mrchristoph 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,231
  • Joined: 18-August 09
  • Reputation: 76

Posted 12 October 2009 - 05:42 PM

Sorry to be more of a pain, but I'm finding the emails are going to my junk folder - any idea why this might be? Thanks
0

#46 User is offline   Jem 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 288
  • Joined: 20-April 08
  • Reputation: 1
  • Gender:Female
  • Location:Telford, Shrops.
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 13 October 2009 - 09:15 AM

It happens sometimes.

I need more details - what mail provider are you using?
0

#47 User is offline   mrchristoph 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,231
  • Joined: 18-August 09
  • Reputation: 76

Posted 13 October 2009 - 11:58 AM

View PostJem, on 13 October 2009 - 09:15 AM, said:

It happens sometimes.

I need more details - what mail provider are you using?


This is something integrated into the host package I presume? I will try and find out tomight.
0

#48 User is offline   Jem 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 288
  • Joined: 20-April 08
  • Reputation: 1
  • Gender:Female
  • Location:Telford, Shrops.
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 13 October 2009 - 03:54 PM

Sorry, I wasn't specific, I meant what's the mail provider of the recipient address; e.g. gmail, yahoo, or through your own domain (which I guess is what you're saying :) )

I ask because it's easy to whitelist certain incoming mail through some providers.

If you're having these mails sent to an account hosted through your domain, is SpamAssassin enabled on the account?
0

#49 User is offline   mrchristoph 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,231
  • Joined: 18-August 09
  • Reputation: 76

Posted 13 October 2009 - 06:46 PM

ah right I see what you mean - I know this is easy enough to do, but for my comeletely computer-illiterate dad this may prove a challenge! Just wondered if there was anything I could do my end to change it?
0

#50 User is offline   Chris.R 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 54
  • Joined: 14-March 08
  • Reputation: 0
  • Gender:Male
  • Location:Kent (Home) - Brighton (Uni)
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 30 October 2009 - 02:37 AM

View PostEskymo, on 25 November 2008 - 06:14 PM, said:

Anyone have any ideas here. I'd really appreciate the help!

Thanks

E


Hi there,

I had exactly the same problem you had with spam about a year ago and I didnt want to use captcha to stop spam so I came up with the following (Im sure others have done this before) I have never had any spam since :) (touch wood!)

Add the following to your CSS file:
.botcatch {
visibility:hidden;
}


Add a text field to your contact form and assign it the class you made
<input name="fieldname" type="text" value="" class="botcatch" />


then in your PHP code do the following
<?php
// If the Send button is pressed
if ($_POST['submit']) {
	
	// If a bot is attempting to send spam
	if ($_POST['fieldname'] !="") {
	
	//Boot it out of the server
	die();
	} else {
	
	//Enter mail code here 
        
        }
} else {}
?>


This works for me :)

Let me know what you think.

Thanks,
Chris
0

#51 User is offline   KieranA 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 361
  • Joined: 11-November 09
  • Reputation: 7
  • Gender:Male
  • Experience:Nothing
  • Area of Expertise:Nothing

Posted 11 November 2009 - 09:20 PM

View PostAdamConder, on 24 July 2009 - 09:51 AM, said:

Yea they will allow php because I am using MySql queries in php files etc?

I have with: www.zymic.com (my domain is uuuq.com)

Thanks for the fast reply!


You could use something like phpmailer and use a SMTP configuration.
0

#52 User is offline   KieranA 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 361
  • Joined: 11-November 09
  • Reputation: 7
  • Gender:Male
  • Experience:Nothing
  • Area of Expertise:Nothing

Posted 11 November 2009 - 09:41 PM

A quick contact form.. took me about 5mins.

Just dump in an XHTML strict header, validate it and change a few html elements and you have a XHTML strict form.. don't waste your money on dire scripts :)

Ideally you'd implement a CAPTCHA but i'm not going to spend much more time on it.

<?php
// If the Send button is pressed

$submit     =  (isset($_POST['submit'])) ? $_POST['submit'] : FALSE;
$name       =   (isset($_POST['name'])) ? $_POST['name'] : FALSE;
$email      =   (isset($_POST['email'])) ? $_POST['email'] : FALSE;

$sum1       =   (isset($_POST['sum1'])) ? $_POST['sum1'] : FALSE;
$sum2       =   (isset($_POST['sum2'])) ? $_POST['sum2'] : FALSE;
$answer     =   (isset($_POST['answer'])) ? $_POST['answer'] : FALSE;

$errors     =   array();
$success    =   FALSE;

if ($submit) 
{
    if (($sum1+$sum2) == $answer)
    {
        // mail here.
        $success    =   TRUE;
    }
    else
    {
        $errors[]   =   'Answer incorrect.';
    }
    
}

// Some randoms
$number1    =   rand(1,20);
$number2    =   rand(1,20);
?>


<html>
<head>
<title> My Contact form</title>

<style type="text/css">
    label { display:block; }

</style>
</head>

<body>

    <?php if(count($errors) != 0): ?>
    <ul class="errors">
    <?php foreach($errors as $e): ?>
    <li><?php echo $e; ?></li>
    <?php endforeach; ?>
    </ul>
    <?php endif; ?>
    
    <?php if($success): ?>
    <div class="success">Thanks! We'll get back to you shortly.</div>
    <?php endif; ?>

<form action="" method="post">

    <label for="name">Your name: </label>
    <input type="text" name="name" id="name" value="<?php echo (($name) ? $name : ''); ?>" /><br />

    <label for="email">Your email: </label>
    <input type="text" name="email" id="email" value="<?php echo (($email) ? $email : ''); ?>" /><br />

    <p><strong>You're human right?</strong></p>
    
    <p>Please answer this question: What is <?php echo $number1; ?> PLUS <?php echo $number2; ?> <input type="text" name="answer" value="" style="width:40px;" /></p>

    
    <input type="hidden" name="sum1" value="<?php echo $number1 ?>" />
    <input type="hidden" name="sum2" value="<?php echo $number2; ?>" />
    
    <input type="submit" name="submit" value="contact me..." />
</form>

</body>
</html>

0

#53 User is offline   MG1878 

  • Expert
  • PipPipPipPip
  • Group: Members
  • Posts: 508
  • Joined: 07-April 08
  • Reputation: 7
  • Gender:Male
  • Location:The world of MiGa
  • Experience:Nothing
  • Area of Expertise:Nothing

Posted 05 December 2009 - 11:42 PM

I might be a bit dozy but when I copied the code into my html page I got this error - "Fatal error: Call to undefined function get_data() in C:\wamp\www\contact-us.php on line 20"

Anyone know what I am doing wrong? I have amended the php part of it with my email address and website address so am unsure what to do and would really appreciate some help

Thanks
0

#54 User is offline   tonychang 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 127
  • Joined: 10-January 10
  • Reputation: 1
  • Gender:Male
  • Location:northants
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 23 February 2010 - 10:05 AM

I've only just started dabbling with script and using it in web pages. I tried a couple of others first but thanks to the advice on here tried this one and got it to work here:

http://www.anthonypa...rs/booking.html

I too would like to know what exactally I need to add to the script to replace :
<p>Your mail was successfully sent.</p>
with a thank you page of my own creation?

cheers,
t.c.
0

#55 User is offline   Ade 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 105
  • Joined: 22-February 09
  • Reputation: 1
  • Gender:Male
  • Location:UK
  • Experience:Advanced
  • Area of Expertise:Web Designer

Posted 21 March 2010 - 05:15 PM

@ tonychang:

Replace
echo '<p>Your mail was successfully sent.</p>';

with:
header('location: filepath of success page');

0

#56 User is offline   iisakki 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 10-August 09
  • Reputation: 0
  • Gender:Male
  • Location:Espoo
  • Experience:Intermediate
  • Area of Expertise:Coder

Posted 14 April 2010 - 11:53 AM

RuubikCMS has now a contact form that also works as stand-alone PHP script. It features:

  • XHTML 1.0 Strict
  • No tables
  • Simple CSS styling with 2 included layout options
  • User defined fields in the settings code (selects, text inputs, message and checkboxes)
  • Mark certain fields as required
  • Verification of required fields (server side)
  • Verification for email header & html input injection
  • Validation of email address (server side)
  • Google AdWords Conversions tracking option
  • Optional robot question
  • Various settings for customization


The demo is located here and the script can be downloaded from the RuubikCMS forum topic.
0

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users