Mok Posted October 18, 2008 Share Posted October 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
philipolson Posted October 18, 2008 Share Posted October 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted October 18, 2008 Share Posted October 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.