Jump to content
Killersites Forums

gilbertsavier

Member
  • Posts

    5
  • Joined

  • Last visited

Everything posted by gilbertsavier

  1. Hi, Going to try to explain this as best I can. I have a bunch of stuff in a database and I need to display this info within a table. This isn't a problem at all but, I need it to only display 3 td tags per line and then move on to the row. so i need it to do : code: My First Row My First Row 2 My First Row 3 My Second Row My Second Row 2 My Second Row 3 and continue to do this through every entry in the database table. so I have something like this that will display the info: code: for ($i = 1; $i <= $num; $i++){ $chairArray = mysql_fetch_array($chairResult); $chairName = $chairArray['name']; $chairDescription = $chairArray['description']; $chairImage = $chairArray['image']; echo " echo " "; echo ""; echo " "; echo $chairName; echo " "; echo " "; } ------------------------------------ Thanks & regards Lokananth
  2. Hi, Now we can create our upload.php file. To start we'll check that the file upload is safe by setting a list of allowed filetypes and disallowing all other file uploads. This will prevent people from uploading malicious files. Then we will check the filesize to prevent large files from being uploaded. <?php // Configuration - Your Options $allowed_filetypes = array('.jpg','.gif','.bmp','.png'); // These will be the types of file that will pass the validation. $max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB). $upload_path = './files/'; // The place the files will be uploaded to (currently a 'files' directory). $filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension). $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename. // Check if the filetype is allowed, if not DIE and inform the user. if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); // Now check the filesize, if it is too large then DIE and inform the user. if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); // Check if we can upload to the specified path, if not DIE and inform the user. if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); // We'll start handling the upload in the next step ?> It's worth noting, that by default PHP will not handle file uploads larger than 2MB, if you require PHP to handle larger files then you must first set upload_max_filesize and post_max_size in your php.ini file to be larger than 2MB. Now that we know we have a suitably small file of a safe filetype we can upload it to where we want it to go. Using the same file: <?php // Configuration - Your Options $allowed_filetypes = array('.jpg','.gif','.bmp','.png'); // These will be the types of file that will pass the validation. $max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB). $upload_path = './files/'; // The place the files will be uploaded to (currently a 'files' directory). $filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension). $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename. // Check if the filetype is allowed, if not DIE and inform the user. if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); // Now check the filesize, if it is too large then DIE and inform the user. if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); // Check if we can upload to the specified path, if not DIE and inform the user. if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); // Upload the file to your specified path. if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) echo 'Your file upload was successful, view the file here'; // It worked. else echo 'There was an error during the file upload. Please try again.'; // It failed . ?> ------------------------- Thanks & regards Lokananth
  3. Hi, I have a form that asks the applicant for previous involvement. They have the option of entering up to three rows and after they press submit the computer needs to enter possible multiple rows. Here is my form code: Other involvement during high school, college (clubs, sports, work, volunteer, etc.): Activity Position Start Date End Date Here is the insert1.php file <?php $con = mysql_connect("localhost","Application","*******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("CpaApp", $con); //Assign each array to a variable foreach($_POST['Activity'] as $row=>$Act) { $Activity=$Act; $Position=$_POST['Position'][$row]; $StartDate=$_POST['StartDate'][$row]; $EndDate=$_POST['EndDate'][$row]; } //enter rows into database foreach($_POST['Activity'] as $row=>$Act) { $Activity=mysql_real_escape_string($Act); $Position=mysql_real_escape_string($_POST['Position'][$row]); $StartDate=mysql_real_escape_string($_POST['StartDate'][$row]); $EndDate=mysql_real_escape_string($_POST['EndDate'][$row]); } $involv = "INSERT INTO Involvement (Activity, Position, StartDate, EndDate) VALUES ('.$Activity.','.$Position.','.$StartDate.','.$EndDate.')"; if (!mysql_query($involv,$con)) { die('Error: ' . mysql_error()); } echo "$row record added"; mysql_close($con) ?> ------------------------------- Thanks & regards Lokananth [Link Deleted]
  4. Dear fellow web developer, Whether you are a JavaScript novice or a seasoned professional, JavaScript Editor turns your website into the real magnet for your visitors - and gives you the edge to set you miles apart from your competitors. If you are like me, you are probably using Dreamweaver, Front Page or some other visual HTML editor for your web design. They do a great job in many ways, but have you ever tried to use them to do any of the following: * Add rollover multilevel menu to your pages * Make sure people enter a valid email * Hide your email from spammers, but show it to visitors, * Design games that work on multiple browsers and operating systems * Validate a form and make sure every field is entered correctly * Add sliders, calendars, color selectors and other elements not supported by HTML * Update just one portion of your web page * Debug your JavaScript code and eradicate logical errors * Draw ovals, circles, lines, arrows and polygons on your web pages * Add a countdown, text effect, tooltips * Write PHP scripts, design XHTML pages, create CSS styles and XML files To design a great website, basic support for JavaScript that visual editors and competing code editors are offering is no longer enough. -------------------- Thanks & regards Lokananth [Link Deleted[
  5. Hi, I am trying to validate a form, and am getting the error messages as needed, but it submits the form anyway. Here is the Java: function validate (form){ var returnValue = true; var email = CSLavRequestForm.email.value; var phone = CSLavRequestForm.phoneNumber.value; var groupName = CSLavRequestForm.workshopName.value; if (email.length < 6){ returnValue = false; alert("Please Enter Valid email"); CSLavRequestForm.email.focus(); } if (phone.length < 10){ returnValue = false; alert("Please Enter Valid Phone Number"); CSLavRequestForm.phone.focus(); } if (groupName.length < 3){ returnValue = false; alert("Please Enter Valid Workshop/Region"); CSLavRequestForm.groupName.focus(); } return returnValue; } and the form line in the html: I am stuck! Benn working on this for way too long Thanks & Regards, Lokananth
×
×
  • Create New...