Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: Php 5

  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    40
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Php 5

    I have a contact form which users can write a message a click submit. I want it to send all messages to a email address but its not working. I herd I need PHP 5 for this to work. My question is how to I DL php 5 and do i need to do anything to it after i DL or just put it in the site folder. My next *dumb* question is do I need a server or domain to have the messages sent work? Thanks

    submit.php
    Code:
    <?php
    
    /* config start */
    
    $emailAddress = 'xxx@hotmail.com';
    
    /* config end */
    
    
    require "../php/class.phpmailer.php";
    
    session_name("fancyform");
    session_start();
    
    
    foreach($_POST as $k=>$v)
    {
    	if(ini_get('magic_quotes_gpc'))
    	$_POST[$k]=stripslashes($_POST[$k]);
    	
    	$_POST[$k]=htmlspecialchars(strip_tags($_POST[$k]));
    }
    
    
    $err = array();
    
    if(!checkLen('name'))
    	$err[]='The name field is too short or empty!';
    
    if(!checkLen('email'))
    	$err[]='The email field is too short or empty!';
    else if(!checkEmail($_POST['email']))
    	$err[]='Your email is not valid!';
    
    if(!checkLen('subject'))
    	$err[]='You have not selected a subject!';
    
    if(!checkLen('message'))
    	$err[]='The message field is too short or empty!';
    
    if((int)$_POST['captcha'] != $_SESSION['expect'])
    	$err[]='The captcha code is wrong!';
    
    
    if(count($err))
    {
    	if($_POST['ajax'])
    	{
    		echo '-1';
    	}
    
    	else if($_SERVER['HTTP_REFERER'])
    	{
    		$_SESSION['errStr'] = implode('<br />',$err);
    		$_SESSION['post']=$_POST;
    		
    		header('Location: '.$_SERVER['HTTP_REFERER']);
    	}
    
    	exit;
    }
    
    
    $msg=
    'Name:	'.$_POST['name'].'<br />
    Email:	'.$_POST['email'].'<br />
    IP:	'.$_SERVER['REMOTE_ADDR'].'<br /><br />
    
    Message:<br /><br />
    
    '.nl2br($_POST['message']).'
    
    ';
    
    
    $mail = new PHPMailer();
    $mail->IsMail();
    
    $mail->AddReplyTo($_POST['email'], $_POST['name']);
    $mail->AddAddress($emailAddress);
    $mail->SetFrom($_POST['email'], $_POST['name']);
    $mail->Subject = "A new ".mb_strtolower($_POST['subject'])." from ".$_POST['name']." | contact form feedback";
    
    $mail->MsgHTML($msg);
    
    $mail->Send();
    
    
    unset($_SESSION['post']);
    
    if($_POST['ajax'])
    {
    	echo '1';
    }
    else
    {
    	$_SESSION['sent']=1;
    	
    	if($_SERVER['HTTP_REFERER'])
    		header('Location: '.$_SERVER['HTTP_REFERER']);
    	
    	exit;
    }
    
    function checkLen($str,$len=2)
    {
    	return isset($_POST[$str]) && mb_strlen(strip_tags($_POST[$str]),"utf-8") > $len;
    }
    
    function checkEmail($str)
    {
    	return preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $str);
    }
    
    ?>

  • #2
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    firstly, are you using a local host, or are you being hosted by a hosting service?

    secondly, if you are using a hosting service, I think alomst every single host out there at the moment is using php 5, and you cannot simply place php 5 in a folder on your server and make it work, the host has to update their servers.

    thirdly, even local host servers such as Wamp server have options to download many different versions of php, but their "recommended" download is usually the latest version of php.

    so what i feel would be the answer to your question, is, yes you will need a version of php, however you can only use the one your host offers, or if using local host programs, you can download the latest that that program offers from their site.

    I hope this has answered your question.

    Dan
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • Users who have thanked Dan13071992 for this post:

    kamaro (01-29-2012)

  • #3
    New Coder
    Join Date
    Jan 2012
    Posts
    40
    Thanks
    8
    Thanked 0 Times in 0 Posts
    You definitely answered my question. No I do not have a host yet. Just wondering now if you know any good FREE ones I can use for now just to see if this contact form feature works properly.

  • #4
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    im sorry, i dont know any free hosts :s i know a cheap host if that helps? if so I dont think Im allowed to post it here as it might be classed as advertising, however if a moderator wants to step in and let me know then Im sure that if you would like those details and its ok with the mods, i can share the link with you.

    Glad I could help.

    Dan
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #5
    New Coder
    Join Date
    Jan 2012
    Posts
    40
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Ok well thanks anyway

  • #6
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    No problem.

    I hope you get it working soon, and you can find hosting ok. If I stumble accross any free hosts, Ill let you know. although im sure you could probably do a quick google search and find tons

    All the best.

    Dan
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #7
    Regular Coder
    Join Date
    Jan 2012
    Posts
    271
    Thanks
    2
    Thanked 65 Times in 65 Posts
    just google: free web hosting with php

    there's a million million million of them....

    well, maybe not quite that many..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •