form
-
(HTML) Form element arrays
Sometimes you might want to group form elements in arrays. Here’s a way to do that: [html] <form> <input type="text" name="textboxes[]"> <input type="text" name="textboxes[]"> <input type="text" name="textboxes[]"> </form> [/html] The structure of the $_POST array will then be: [php] Array ( [textboxes] => Array ( [0] => value 1 [1] => value 2 [2] =>…
-
(PHP) simple picture/file upload script
Here is a simple tutorial script that uploads a file to a folder on the server. In this example it is assumed that the file is an image and it will be outputted on screen in an img-tag. But the file uploading mechanics works for any file type. [php] <?php if(isset($_POST[‘submit’])) { $temp_name = $_FILES["file"]["tmp_name"];…
-
(PHP) Simple e-mail contact form.
A simple contact form, just for reference. Will add more info later on… [php] <?php if (isset($_POST[‘submit’])) { $name = $_POST[‘name’]; //name of sender $email = $_POST[’email’]; //e-mail of sender $email = stripslashes($email); $subject = $_POST[‘subject’]; //e-mail subject $subject = str_replace(array("\r\n","\r","\n"), "", $subject); //remove any linebreaks to keep from code injections $message = $_POST[‘message’]; //…
-
Hide elements with radio buttons
Sometimes you want to show or hide certain elements of a form, depending on the selection of a radiobutton. I am by no means any javascript ninja, but this is one simple way I came up with: This could apply to any element. For example, you could put a whole bunch of elements in…
-
Hide elements with checkbox
This is a slightly edited version of this post. Just to make it work with a checkbox instead of radio buttons. [html] <html> <head> <script type="text/javascript"> function DisplayElement(checked) { if (checked) { document.getElementById(‘text’).style.display = ”; } else { document.getElementById(‘text’).style.display = ‘none’; } } </script> </head> <body> <form name="form"> <input type="checkbox" onclick="DisplayElement(this.checked)" checked/> <input…