Jump to content

my first ever php script for a form- it doesnt work, I could use major help.


ponies3387

Recommended Posts

I created a form in dreamweaver that includes

-a text box

-a file upload

-three check boxes

-submit button.

 

heres the code for it:

 

    <form action="process.php" method="post" enctype="multipart/form-data" name="Form" class="style1" id="Form">

         

        <div align="left">

                <blockquote>

                  <p><span class="style11">E-mail:          </span>

                    <input type="text" name="Email" id="Email" />

                    <br />

                    <span class="style6">I have text here</span><br />

                    <br />

                    <br />

                    <span class="style11"> Image:</span>

                    <input type="file" name="Image" id="Image" />

                    <br />

                    <br />

                    <br />

                    <span class="style12">more text here</span><br />

                    <br />

                    <input type="checkbox" name="1" id="1" />

                    standard retouch  <br />

                    <span class="style6">blah blah checkbox</span><br />

                    <input type="checkbox" name="2" id="2" />

                    anothercheckbox description<br />

                    <input type="checkbox" name="3" id="3" />

                    last checkbox<br />

                    <br />

                    More options will be added in the near future!<br />

                    <br />

                    <br />

                    <input type="submit" name="Submit" id="Submit" value="Submit" />

                    <span class="style6">final text</span><br />

                    <br />

                  </p>

                </blockquote>

              </div>

        </form>

 

Heres the script I created for it:

 

 

    <?php

      $email = $_REQUEST['Email'] ;

      $file = $_REQUEST['Image'] ;

      $check1 = $_REQUEST['1'] ;

      $check2 = $_REQUEST['2'] ;

      $check3 = $_REQUEST['3'] ;

      $submit = $_REQUEST['Submit'] ;

 

 

      mail( "info@changedforprivacy.com", "New Sent Photo",

        $message, "From: $email" );

      header( "Location: http://www.changedforprivacy.com/SendSuccess.html" );

    ?>

 

 

 

As you can see, I want the results e-mailed to me since thats the only way I know how, and I want only myself to see it.

So far, my script sends me a blank e-mail.

 

Any help is appreciated, this is my first one ever, and im having a lot of trouble understanding this.

 

I also here that you have to make your script secure, and I have no clue how to do that.

Ive looked at so many tutorials, and im just not getting it.  ???

 

Please help me make my script work the way it should!!  ;D

 

 

Link to comment
Share on other sites

???

 

okkk...so im confused what you mean...do I have to create a message area in the form itself in dreamweaver? because I dont want to allow users to write a message, I just want to be emailed the results. Im really new to this, what do I write and where do I write it!???? also, how do I make it secure???

Link to comment
Share on other sites

okkk...so I changed my script to this:

 

but it still doesnt work. If anyone can give me some more specific ways to fix this, that would be helpful, I dont know what im doing obviously.

 

<?php

  $email = $_REQUEST['Email'] ;

  $file = $_REQUEST['Image'] ;

  $check1 = $_REQUEST['1'] ;

  $check2 = $_REQUEST['2'] ;

  $check3 = $_REQUEST['3'] ;

  $submit = $_REQUEST['Submit'] ;

 

$message = "

Email address = $email

Checkbox1 = $check1

Checkbox2 = $check2

Checkbox3 = $check3";

 

  mail( "info@changed.com", "New Sent Photo",

    $message, "From: $email" );

  header( "Location: http://www.changed.com/SendSuccess.html" );

?>

 

:'(

Link to comment
Share on other sites

ahh i get you, you want the results of the check box to be emailed to you ayyz.... well what you have to do is something like this (its a contact form i made up, i commented it so you can understand it a bit better okayz);

<?php
//if the contact form was posted run the following
if (isset($_POST['Subject'])) {
//the email and name im getting from a session but you could get it from a text box etc
	$email = $_SESSION['email'];
	$name = $_SESSION['name'];
	$subject = $_POST['Subject'];
//if you are using a checkbox just use $_POST whatever the checkbox name is
	$message = $_POST['Message'];
//this does a little check to make sure that they are using a real email add-makes it a bit more secure (if your really worried you can use gpl image captcha but i wouldnt worrie unless its large scale.
  if(!$email == "" && (!strstr($email,"@") || !strstr($email,".")))
{
//if its not real echo out a wrong email msg
echo "<h2>Enter valid e-mail</h2>\n ";
$badinput = "<h2>Email was NOT submitted</h2></div> \n";
echo $badinput;
echo "<br>";
include('footer.php');
//then just kills the page
die();
}
//if the form is all correct email the message to the following
	$to = 'name@whatever.com';
	$header = "from:$name <$email>";
//then just put the message together, if your message is a few checkboxes instead of using $message just use the seperate boxes then just construct the $message, eg: $message = $box1 $box2;
	$success = mail($to, $subject, $message, $header);
if ($success) {
//success message
echo 'Thank you for your question/feedback.';
} else {
//fail message
echo "Email could not be sent $to.";
}

} else {
?>
<table width="50%" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td>
  <form action="" method="post">
  <table width="328" height="183" border="0" align="center" cellspacing="0">
    <tr>
      <td valign="top">Subject</td>
      <td><label>
        <input name="Subject" type="text" class="text" id="Subject" size="25" />
      </label></td>
    </tr>
    <tr>
      <td valign="top">Message</td>
      <td><label>
        <textarea name="Message" cols="23" rows="8" class="text" id="Message"></textarea>
      </label></td>
    </tr>
  </table><div align="center"><input name="Submit" type="submit" class="text" value="Send" /></div>
  </form>
  </td>
</table></font>
<?php } ?>

 

Good luck

Link to comment
Share on other sites

thanks, but I still have a problem with the browse file field not send the image the user send to my e-mail. But thanks for the security help! ;D

The checkboxes work fine, I just cant figure out how to allow the user to send a file in the e-mail!

 

If anyone can show me whats wrong with my form/script which is not sending me the browse file field input, I would really really appreciate it!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.