WordPress.org

Ready to get started?Download WordPress

Forums

PHP form help. (5 posts)

  1. danny_getextra
    Member
    Posted 1 year ago #

    Hi guys,

    I've created a simple php form and am trying to get it to return empty fields to me for the email here's what ive got.

    <?php
    if(isset($_POST))
    
    {
    
        $name = check_input($_POST['form2mail_name']);
        $email = check_input($_POST['form2mail_email'], "Enter an email address please");
        $telp = check_input($_POST['form2mail_tel']);
        $address = check_input($_POST['texform2mail_address']);
        $nature = check_input($_POST['form2mail_nature_of_interest']);
        $thickness = check_input($_POST['form2mail_thickness']);
        $projectName = check_input($_POST['form2mail_project_name']);
    	$sample = check_input($_POST['form2mail_samples']);
    
        //process sent message
        $to = 'danny@getextra.co.uk';
        $subject = 'Reqeust Info parapan.co.uk';
        $message = "Name : " . $name ."\n" ;
        $message .= "Address : " . $address ."\n" ;
        $message .= "Nature : " . $nature ."\n" ;
        $message .= "Thickness : " . $thickness ."\n" ;
        $message .= "Project Name : " . $projectName ."\n" ;
        $message .= "Sample : " . $sample ."\n" ;
        $header = "Form : " . $email; 
    
        $sentmail = mail($to, $subject, $message, $header);
    if($sentmail) {
    header('Location: http://79.170.44.86/parapan.co.uk/colours/index.html');
    
    }
    
    }
    
    ?>
    <? php
    function check_input($data, $problem='')
    {
        $data = trim($data);
        $data = stripslashes($data);
        $data = htmlspecialchars($data);
        if ($problem && strlen($data) == 0)
        {
            die($problem);
        }
        return $data;
    }
    ?>
  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    Is this for a WordPress site?

  3. danny_getextra
    Member
    Posted 1 year ago #

    Yes it is for my wordpress site

  4. danny_getextra
    Member
    Posted 1 year ago #

  5. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    I'd suggest that you start looking at some contact form plugins - unless you fancy building your own form plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.