Jump to content

Help - Web form


Mok

Recommended Posts

Hi I would like to combine a webform where people can post comments with their name and also upload a file at the same time.

 

I cam up with this, but it deon't work:

 

form:

<form action="thanks.php" method="POST" class="style7">

      <p>Name:

        <input type="TEXT" name="name">

      </p>

      <p> Email:

        <input type="TEXT" name="email">

        </p>

      <p>Comment:

        <input type="text" name="email2" />

      </p>

      <p>comment</p>

      <p>

        <label>

          <textarea name="ED" id="ED" cols="45" rows="5"></textarea>

          </label>

      </p>

      <p>Comment</p>

      <p>Upload</p>

      <p><input type="hidden" name="MAX_FILE_SIZE" value="100000" />

Choose a file to upload: <input name="uploadedfile" type="file" /><br />

<input name="Button" type="button" value="Upload File" />

 </p>

      <p>

        <input type="SUBMIT" name="Submit" value="ok">

        </p>

    </form>

 

Thanks.php

<script language="php">

$email = $HTTP_POST_VARS;

$mailto = "myemail@gmail.com";

$mailsubj = "Form submission";

$mailhead = "From: $email\n";

reset ($HTTP_POST_VARS);

$mailbody = "Values submitted from web site form:\n";

while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }

if (!eregi("\n",$HTTP_POST_VARS)) { mail($mailto, $mailsubj, $mailbody, $mailhead); }

</script>

 

Can someone please help improve it so I can use it, thank you very much in advance.

 

 

 

Mok

 

 

 

Link to comment
Share on other sites

First, I've never seen anyone use the <script> syntax for PHP before (sure it exists, however, make life easier and don't use it) so I suggest using PHP tags (<?php ?>) instead.

 

Second, your code is completely broken so I suggest you go find some beginning PHP tutorials and go through them before writing code. Sorry to be frank, and possibly you will not like this response, but it's clear you lack much understanding of PHP to begin writing such code because it's clear you cut-n-pasted a few snippets and hoped for the best... something we all did or tried to do early in our PHP careers! :) But trust me, it's not worth it.

 

Third, when you start writing similar examples I suggest starting very very simply like a form that passes one value, then have another page that prints out that value, and from there expand your form.

Link to comment
Share on other sites

I suggest starting very very simply like a form that passes one value, then have another page that prints out that value, and from there expand your form.

 

like so...

<?php
if(isset($_POST['text'])) {
   echo $_POST['text'];
} else {
   echo "<form action=\"thispage.php\" method=\"post\">";
   echo "<input type=\"text\" name=\"text\" />";
   echo "<input type=\"submit\" />";
   echo "</form>";
}
?>

 

Regards ACE

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.