Form Submission Problem

  • (2 Pages)
  • +
  • 1
  • 2

27 Replies - 1231 Views - Last Post: 14 June 2013 - 08:01 AM Rate Topic: -----

#16 mattmandery  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 17-May 13

Re: Form Submission Problem

Posted 17 May 2013 - 06:21 PM

You guys are awesome. Finally was able to access my site and it said it was submitted successfully. Still havnt received the email though :/ Ah well I guess you gotta win one victory at a time. Does anyone know if gmail has conflict with php mail function?
Was This Post Helpful? 0
  • +
  • -

#17 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 451
  • View blog
  • Posts: 1,947
  • Joined: 30-April 10

Re: Form Submission Problem

Posted 17 May 2013 - 07:51 PM

There are many possable issues:

  • code issues
  • xampp mail server not running
  • could be in spam folder


I hope this helps you.
Was This Post Helpful? 0
  • +
  • -

#18 mattmandery  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 17-May 13

Re: Form Submission Problem

Posted 17 May 2013 - 08:41 PM

Ok so i finally got it to read the php and it confirms that it was sent but I have tried multiple email services (gmail, a school email, and also hotmail) and non of them send. Do I have a syntex error or missing some info?
<?php
/* Subject and Email Variables */
	$emailSubject = 'New Player Information to be reviewed';
	$webMaster = 'mattmandery@hotmail.com';
/* Gathering Data variables */
	$firstName = $_POST['firstName'];
	$lastName = $_POST['lastName'];
	$years = $_POST['years'];
	$highSchool = $_POST['highSchool'];
	$email = $_POST['email'];
	$phone = $_POST['phone'];
	$gradYear = $_POST['gradYear'];
	$honors = $_POST['honors'];
	$info = $_POST['info'];
	
	$body = <<<EOD
<br><hr><br>
First Name: $firstName <br>
Last Name: $lastName <br>
Years Played: $years <br>
High School Attended: $highSchool <br>
Email: $email <br>
Phone Number: $phone <br>
Year Graduated: $gradYear <br>
High School Honors/Lacrosse Awards: $honors <br>
Misc Info: $info <br>
EOD;

	$headers = "From: $email\n";
	$headers .= "Content-type: text/html\n";
	$success = mail($webMaster, $emailSubject, $body, $headers);
/* Results rendered as HTML (Confirmed)*/
	$theResults = <<<EOD
<html>
<head>
<title>Email Confirmed</title>
</head>

<body>
Thank your for submitting your information.  Your information has been received and you will be hearing from us very shortly!  GO CARDINALS! <br>

Go back to homepage: <a href = "http://localhost/BallStateMensLacrosse"/> Home Page</a>
</body>
</html>
EOD;

echo "$theResults";
?>

Was This Post Helpful? 0
  • +
  • -

#19 Slice  Icon User is offline

  • sudo pacman -S moneyz


Reputation: 245
  • View blog
  • Posts: 719
  • Joined: 24-November 08

Re: Form Submission Problem

Posted 18 May 2013 - 03:26 AM

When setting up a localhost machine for testing, it doesn't come with a lot of preinstalled software you're likely to get on a rented server (like godaddys for example). There are two options for sending mail through php:

1) install a mail server application.

2) You can use PHPMailer to connect to an SMTP email account (like your gmail account) and send it via that.

I prefer the latter for testing as it's much easier to set up. You can download PHPMailer here, and heres a quick example of connecting to your gmail account:

<?php
    require("class.phpmailer.php"); //the file you downloaded, make sure the path is correct

    $mail = new PHPMailer();

    $mail->IsSMTP();  // telling the class to use SMTP
    $mail->SMTPAuth   = true; // SMTP authentication
    $mail->Host       = "smtp.gmail.com"; // SMTP server
    $mail->Port       = 465; // SMTP Port
    $mail->Username   = "john.doe@gmail.com"; // SMTP account username
    $mail->Password   = "your.password";        // SMTP account password

    $mail->SetFrom('john.doe@gmail.com', 'John Doe'); // FROM
    $mail->AddReplyTo('john.doe@gmail.com', 'John Doe'); // Reply TO

    $mail->AddAddress('jane.doe@gmail.com', 'Jane Doe'); // recipient email

    $mail->Subject    = "First SMTP Message"; // email subject
    $mail->Body       = "Hi! \n\n This is my first e-mail sent through Google SMTP using PHPMailer.";

    if(!$mail->Send()) {
      echo 'Message was not sent.';
      echo 'Mailer error: ' . $mail->ErrorInfo;
    } else {
      echo 'Message has been sent.';
    }
?>



Credit for this example goes to Mihai Iorga at SO

This post has been edited by Slice: 18 May 2013 - 03:28 AM

Was This Post Helpful? 1
  • +
  • -

#20 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3838
  • View blog
  • Posts: 13,595
  • Joined: 12-December 12

Re: Form Submission Problem

Posted 18 May 2013 - 03:35 AM

I use this free Test Mail Server Tool, it's dead simple.
Was This Post Helpful? 2
  • +
  • -

#21 mattmandery  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 17-May 13

Re: Form Submission Problem

Posted 18 May 2013 - 07:07 AM

Thank you to both of you. I will be trying both of these solutions after I drag myself out of bed haha. Cheers!
Was This Post Helpful? 0
  • +
  • -

#22 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 451
  • View blog
  • Posts: 1,947
  • Joined: 30-April 10

Re: Form Submission Problem

Posted 19 May 2013 - 11:09 AM

View Postandrewsw, on 18 May 2013 - 10:35 AM, said:

I use this free Test Mail Server Tool, it's dead simple.


This is awesome. Thanks for the post.
Was This Post Helpful? 0
  • +
  • -

#23 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3838
  • View blog
  • Posts: 13,595
  • Joined: 12-December 12

Re: Form Submission Problem

Posted 19 May 2013 - 11:36 AM

View Postlaytonsdad, on 19 May 2013 - 06:09 PM, said:

View Postandrewsw, on 18 May 2013 - 10:35 AM, said:

I use this free Test Mail Server Tool, it's dead simple.


This is awesome. Thanks for the post.

Glad to pass it on, brilliantly simple!
Was This Post Helpful? 0
  • +
  • -

#24 murume  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 50
  • Joined: 21-June 11

Re: Form Submission Problem

Posted 29 May 2013 - 04:45 AM

I have a problem of my own. I don't know if I should have started a new thread. Some forums discourage people who start threads on issues that have similar threads running.
Somebody please help with the following code. I created a form with the following code:

<?php
        if (!isset($_POST['howmany'])) {
            echo '<form enctype="multipart/form-data" method="post" action="upload.php" name="upload">';
            echo 'How many images do you want to upload?<br><input type="text" name="howmany" value="1"><input type="submit" value="Upload">';
            exit();
        }
        $howmany = $_POST['howmany'];
        echo '<form enctype="multipart/form-data" method="post" action="uploaded.php?howmany='.$howmany.'" name="upload">';
        
        echo ' <input type="hidden" value="1" name="token">';
       
        for ($i = 1; $i <= $howmany; $i++) {
            echo '<pre><input name="imgfile' . $i . '" type="file">';
            echo ' Descride the image <input maxlength="29" size="30" name="desc' . $i . '" value=""><br></pre>';
        }
        echo '<input type="hidden" name="howmany" value"'.$howmany.'"><input type="submit" value="Upload Images"></form>';
        ?>


and it submits to a file with the following code:

<?php
if(!isset($_POST['token']))
	exit("No Direct Access!");

$uploaddir = 'images/';
$num = $_POST["howmany"];

for($i=1; $i<=$num; $i++){
	$imgfile = "imgfile".$i;
	$uploadfile = $uploaddir . basename($_FILES[$imgfile]['name']);
	$imgname = $_FILES[$imgfile]['name'];
	
	echo '<pre>';
	if (move_uploaded_file($_FILES[$imgfile]['tmp_name'], $uploadfile)) {
	    echo "$imgname was successfully uploaded.\n";
	} else {
	    echo "Ooops! Image $i failed to upload.\n";
}
}
?>


My troubleshooting efforts revealed that the form is actually parsing something as 'howmany' but for some reason I can use whatever has been parsed. everything works fine when I replace $_POST['howmany'] with an actual integer.
Whats going on here?

This post has been edited by murume: 29 May 2013 - 04:49 AM

Was This Post Helpful? 0
  • +
  • -

#25 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3577
  • View blog
  • Posts: 10,444
  • Joined: 08-June 10

Re: Form Submission Problem

Posted 29 May 2013 - 05:10 AM

View Postmurume, on 29 May 2013 - 01:45 PM, said:

Whats going on here?

automatic type conversion. as long as $num is not falsy, the conversion to INT will give 1 and then you got at least one loop cycle.

PS. 1st code block line #16, missing = after value-attribute.
Was This Post Helpful? 1
  • +
  • -

#26 murume  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 50
  • Joined: 21-June 11

Re: Form Submission Problem

Posted 03 June 2013 - 06:35 AM

Quote

automatic type conversion. as long as $num is not falsy, the conversion to INT will give 1 and then you got at least one loop cycle.


Any suggestions on how to fix it?

Quote

PS. 1st code block line #16, missing = after value-attribute.

thanks!
Was This Post Helpful? 0
  • +
  • -

#27 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3577
  • View blog
  • Posts: 10,444
  • Joined: 08-June 10

Re: Form Submission Problem

Posted 03 June 2013 - 06:38 AM

test that $num is what you expect, e.g. with filter functions.

This post has been edited by Dormilich: 03 June 2013 - 06:46 AM

Was This Post Helpful? 0
  • +
  • -

#28 murume  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 50
  • Joined: 21-June 11

Re: Form Submission Problem

Posted 14 June 2013 - 08:01 AM

Quote

automatic type conversion. as long as $num is not falsy, the conversion to INT will give 1 and then you got at least one loop cycle.

Thanks
I used intval() to convert $num to an integer and it worked
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2