PHP - Final Straw In Frustration
I apologize for starting a couple of threads. But I have finally typed out my entire dilemma and could really use support in solving this issue.
I am having an extremely hard time with I am sure a simple solution. I am slightly new at programming, but I know a fair amount to get my by. Anyways... Here's my problem. I am a photographer and I working on a website to teach and train students. I have currently made a very detailed website, but photo uploading management is kicking my butt. I first begin with an iFrame. The code follows, <?PHP include('../functions.php'); if($loggedinid="") { header( 'Location: http://lightgraspers.com/login.php' ) ; } //session_start(); //$_SESSION['pid']=$_SERVER['QUERY_STRING']; //$loggedinid=$_SESSION['uid']; //$_SESSION['pid']=$pid; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Queued Photo Uploader - Standalone Showcase from digitarald.de</title> <meta name="author" content="Harald Kirschner, digitarald.de" /> <meta name="copyright" content="Copyright 2009 Harald Kirschner" /> <!-- Framework CSS --> <link rel="stylesheet" href="http://github.com/joshuaclayton/blueprint-css/raw/master/blueprint/screen.css" type="text/css" media="screen, projection"> <link rel="stylesheet" href="http://github.com/joshuaclayton/blueprint-css/raw/master/blueprint/print.css" type="text/css" media="print"> <!--[if IE]><link rel="stylesheet" href="http://github.com/joshuaclayton/blueprint-css/raw/master/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]--> <!--[if lte IE 7]> <script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script> <![endif]--> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools.js"></script> <script type="text/javascript" src="source/Swiff.Uploader.js"></script> <script type="text/javascript" src="source/Fx.ProgressBar.js"></script> <script type="text/javascript" src="http://github.com/mootools/mootools-more/raw/master/Source/Core/Lang.js"></script> <script type="text/javascript" src="source/FancyUpload2.js"></script> <!-- See script.js --> <script type="text/javascript"> //<![CDATA[ /** * FancyUpload Showcase * * @license MIT License * @author Harald Kirschner <mail [at] digitarald [dot] de> * @copyright Authors */ window.addEvent('domready', function() { // wait for the content // our uploader instance var up = new FancyUpload2($('demo-status'), $('demo-list'), { // options object // we console.log infos, remove that in production!! verbose: true, // url is read from the form, so you just have to change one place url: $('form-demo').action, // path to the SWF file path: 'source/Swiff.Uploader.swf', // remove that line to select all files, or edit it, add more items typeFilter: { 'Images (*.jpg, *.jpeg, *.gif, *.png)': '*.jpg; *.jpeg; *.gif; *.png' }, // this is our browse button, *target* is overlayed with the Flash movie target: 'demo-browse', // graceful degradation, onLoad is only called if all went well with Flash onLoad: function() { $('demo-status').removeClass('hide'); // we show the actual UI $('demo-fallback').destroy(); // ... and hide the plain form // We relay the interactions with the overlayed flash to the link this.target.addEvents({ click: function() { return false; }, mouseenter: function() { this.addClass('hover'); }, mouseleave: function() { this.removeClass('hover'); this.blur(); }, mousedown: function() { this.focus(); } }); // Interactions for the 2 other buttons $('demo-clear').addEvent('click', function() { up.remove(); // remove all files return false; }); $('demo-upload').addEvent('click', function() { up.start(); // start upload return false; }); }, // Edit the following lines, it is your custom event handling /** * Is called when files were not added, "files" is an array of invalid File classes. * * This example creates a list of error elements directly in the file list, which * hide on click. */ onSelectFail: function(files) { files.each(function(file) { new Element('li', { 'class': 'validation-error', html: file.validationErrorMessage || file.validationError, title: MooTools.lang.get('FancyUpload', 'removeTitle'), events: { click: function() { this.destroy(); } } }).inject(this.list, 'top'); }, this); }, /** * This one was directly in FancyUpload2 before, the event makes it * easier for you, to add your own response handling (you probably want * to send something else than JSON or different items). */ onFileSuccess: function(file, response) { var json = new Hash(JSON.decode(response, true) || {}); if (json.get('status') == '1') { file.element.addClass('file-success'); file.info.set('html', '<strong>Image was uploaded:</strong> ' + json.get('width') + ' x ' + json.get('height') + 'px, <em>' + json.get('mime') + '</em>)'); } else { file.element.addClass('file-failed'); file.info.set('html', '<strong>An error occured:</strong> ' + (json.get('error') ? (json.get('error') + ' #' + json.get('code')) : response)); } }, /** * onFail is called when the Flash movie got bashed by some browser plugin * like Adblock or Flashblock. */ onFail: function(error) { switch (error) { case 'hidden': // works after enabling the movie and clicking refresh alert('To enable the embedded uploader, unblock it in your browser and refresh (see Adblock).'); break; case 'blocked': // This no *full* fail, it works after the user clicks the button alert('To enable the embedded uploader, enable the blocked Flash movie (see Flashblock).'); break; case 'empty': // Oh oh, wrong path alert('A required file was not found, please be patient and we fix this.'); break; case 'flash': // no flash 9+ :( alert('To enable the embedded uploader, install the latest Adobe Flash plugin.') } } }); }); //]]> </script> <!-- See style.css --> <style type="text/css"> /** * FancyUpload Showcase * * @license MIT License * @author Harald Kirschner <mail [at] digitarald [dot] de> * @copyright Authors */ /* CSS vs. Adblock tabs */ .swiff-uploader-box a { display: none !important; } /* .hover simulates the flash interactions */ a:hover, a.hover { color: red; } #demo-status { padding: 10px 15px; width: 420px; border: 1px solid #eee; } #demo-status .progress { background: url(assets/progress-bar/progress.gif) no-repeat; background-position: +50% 0; margin-right: 0.5em; vertical-align: middle; } #demo-status .progress-text { font-size: 0.9em; font-weight: bold; } #demo-list { list-style: none; width: 450px; margin: 0; } #demo-list li.validation-error { padding-left: 44px; display: block; clear: left; line-height: 40px; color: #8a1f11; cursor: pointer; border-bottom: 1px solid #fbc2c4; background: #fbe3e4 url(assets/failed.png) no-repeat 4px 4px; } #demo-list li.file { border-bottom: 1px solid #eee; background: url(assets/file.png) no-repeat 4px 4px; overflow: auto; } #demo-list li.file.file-uploading { background-image: url(assets/uploading.png); background-color: #D9DDE9; } #demo-list li.file.file-success { background-image: url(assets/success.png); } #demo-list li.file.file-failed { background-image: url(assets/failed.png); } #demo-list li.file .file-name { font-size: 1.2em; margin-left: 44px; display: block; clear: left; line-height: 40px; height: 40px; font-weight: bold; } #demo-list li.file .file-size { font-size: 0.9em; line-height: 18px; float: right; margin-top: 2px; margin-right: 6px; } #demo-list li.file .file-info { display: block; margin-left: 44px; font-size: 0.9em; line-height: 20px; clear } #demo-list li.file .file-remove { clear: right; float: right; line-height: 18px; margin-right: 6px; } </style> </head> <body> <div class="container"> <!-- See index.html --> <div> <form action="server/script.php" method="post" enctype="multipart/form-data" id="form-demo"> <fieldset id="demo-fallback"> <label for="demo-photoupload"> Upload a Photo: <input type="file" name="Filedata" /> </label> </fieldset> <div id="demo-status" class="hide"> <p><?php echo "$conid", "$loggedin", "$loggedinid", "$pid", $_GET['pid'] ?> <a href="#" id="demo-browse">Browse Files</a> | <a href="#" id="demo-clear">Clear List</a> | <a href="#" id="demo-upload">Start Upload</a> </p> <div> <strong class="overall-title"></strong><br /> <img src="assets/progress-bar/bar.gif" class="progress overall-progress" /> </div> <div> <strong class="current-title"></strong><br /> <img src="assets/progress-bar/bar.gif" class="progress current-progress" /> </div> <div class="current-text"></div> </div> <ul id="demo-list"></ul> </form> </div> </div> </body> </html> I can carry the value of $loggedid over to the iFrame, but then it doesn't go with the server/script.php path. No variables pass through... Here is the script.php information: <?php include('../../functions.php'); // Request log /** * You don't need to log, this is just for the showcase. Better remove * those lines for production since the log contains detailed file * information. */ $result = array(); $result['time'] = date('r'); $result['addr'] = substr_replace(gethostbyaddr($_SERVER['REMOTE_ADDR']), '******', 0, 6); $result['agent'] = $_SERVER['HTTP_USER_AGENT']; if (count($_GET)) { $result['get'] = $_GET; } if (count($_POST)) { $result['post'] = $_POST; } if (count($_FILES)) { $result['files'] = $_FILES; } // we kill an old file to keep the size small //if (file_exists('script.log') && filesize('script.log') > 102400) { // unlink('script.log'); //} //$log = @fopen('script.log', 'a'); //if ($log) { // fputs($log, print_r($result, true) . "\n---\n"); // fclose($log); //} // Validation $error = false; if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name'])) { $error = 'Invalid Upload'; } /** * You would add more validation, checking image type or user rights. * if (!$error && $_FILES['Filedata']['size'] > 2 * 1024 * 1024) { $error = 'Please upload only files smaller than 2Mb!'; } if (!$error && !($size = @getimagesize($_FILES['Filedata']['tmp_name']) ) ) { $error = 'Please upload only images, no other files are supported.'; } if (!$error && !in_array($size[2], array(1, 2, 3, 7, 8) ) ) { $error = 'Please upload only images of type JPEG, GIF or PNG.'; } if (!$error && ($size[0] < 25) || ($size[1] < 25)) { $error = 'Please upload an image bigger than 25px.'; } */ // Processing /** * Its a demo, you would move or process the file like: * * move_uploaded_file($_FILES['Filedata']['tmp_name'], '../uploads/$loggedinid/' . $_FILES['Filedata']['name']); * $return['src'] = '/uploads/$loggedinid' . $_FILES['Filedata']['name']; * * or * * $return['link'] = YourImageLibrary::createThumbnail($_FILES['Filedata']['tmp_name']); * */ if ($error) { $return = array( 'status' => '0', 'error' => $error ); } else { $return = array( 'status' => '1', 'name' => $_FILES['Filedata']['name'] ); // Our processing, we get a hash value from the file $return['hash'] = md5_file($_FILES['Filedata']['tmp_name']); // ... and if available, we get image data $info = @getimagesize($_FILES['Filedata']['tmp_name']); // Specify directory path for your images directory $upload_directory = $_SERVER[DOCUMENT_ROOT] ."/file_upload/uploads/$loggedinid/$pid/"; $fileLoc="file_upload/uploads/$loggedinid/$pid/"; // Check that the images directory exists if(file_exists($upload_directory)) { // Upload file or return error message information $fileUrl = $fileLoc .$_FILES[Filedata][name]; mysql_query("INSERT INTO `homework` SET `uid`='$loggedin', `pid`='$pid', `url`='$fileUrl', `approved`='0'"); if(!move_uploaded_file($_FILES[Filedata][tmp_name], $upload_directory .$_FILES[Filedata][name])) { $error = "Could not upload file " .$_FILES["Filedata"]["name"] ."<br />" .$_FILES; } } else { mkdir("../uploads/$loggedinid/$pid", 0777); // Upload file or return error message information $fileUrl = $fileLoc .$_FILES[Filedata][name]; mysql_query("INSERT INTO `homework` SET `uid`='$loggedinid', `pid`='$pid', `url`='$fileUrl', `approved`='0'"); if(!move_uploaded_file($_FILES[Filedata][tmp_name], $upload_directory .$_FILES[Filedata][name])) { $error = "Could not upload file " .$_FILES["Filedata"]["name"] ."<br />" .$_FILES; } } if ($info) { $return['width'] = $info[0]; $return['height'] = $info[1]; $return['mime'] = $info['mime']; } } // Output /** * Again, a demo case. We can switch here, for different showcases * between different formats. You can also return plain data, like an URL * or whatever you want. * * The Content-type headers are uncommented, since Flash doesn't care for them * anyway. This way also the IFrame-based uploader sees the content. */ if (isset($_REQUEST['response']) && $_REQUEST['response'] == 'xml') { // header('Content-type: text/xml'); // Really dirty, use DOM and CDATA section! echo '<response>'; foreach ($return as $key => $value) { echo "<$key><![CDATA[$value]]></$key>"; } echo '</response>'; } else { // header('Content-type: application/json'); echo json_encode($return); } ?> The files upload correctly, but I need "uid" and the "pid" variables to carry through. This will then allow me to access the students information from the back-end. The files are uploading fine, I need those variables in there for the rest of the script to work. Similar TutorialsI, for some unknown reason, decided to attempt to build my first social networking website for my senior project. I am sort of a dumb dumb when it comes to PHP. For what I am currently working on now I need to display "members" that go to the same "school" and start in the same "semester" according to whomever is currently logged in. I understand $_SESSION['userid'] = mysql_insert_id(); is tracking the current user, but how would I track other information attached to that current user. The "school" and "semester" are tracked within tables outside of the "user" table. Any help at all would be awesome. If you need anymore information let me know. Thanks a trizillion. I have a database that contains results of fantasy football games. I have a query that returns the results of the games team X played against the other teams in the league. The query works perfect in the database. Results are Quote Opponent Name: America Enforcers Wins Losses Draws 1 1 0 Last Game: Week 2 of 2011: 416.6 - 369.8 the query and the php code cycle thru each team that team X has played and brings up team X's record and the results of the last game played. My problem is that the code stops one team short. So Team X played teams A, B, C, D, E but the code only returns teams A, B, C, D E is left off. I can't for the life of me figure out what silly mistake I made. Code: [Select] <?php include_once('../other/functions.php'); $con = mysql_connect($hostname, $username, $password) OR DIE ('Unable to connect to database! Please try again later.'); $db = mysql_select_db($dbname, $con); $thing = $_GET['thing']; $query = "select selected.teamname AS selected_team, selected_score.score AS selected_score, week.week, year, home_id, ". "target_score.score as target_score, target.teamname as targetname, week.ID ". "from owners as selected ". "JOIN game_scores AS selected_score ON selected.owner_id = selected_score.team_id ". "JOIN game_setup ON game_setup.game_id = selected_score.game_id ". "JOIN game_scores AS target_score ON target_score.game_id = game_setup.game_id AND target_score.team_id != selected_score.team_id ". "JOIN owners AS target ON target.owner_id = target_score.team_id ". "JOIN week ON week.week = game_setup.week ". "WHERE selected.owner_id = $thing ". "and target.active = 1 ". "GROUP BY target.teamname, year, week.ID "; $result = mysql_query($query); $row = mysql_fetch_array($result); $result1 = mysql_query($query); $row1 = mysql_fetch_array($result1); if (!$result) { die('Invalid query: ' . mysql_error()); } $wins=0; $losses=0; $draws=0; $last_target = false; echo '<h2>' . $row1['selected_team'] . ' vs. Active Teams</h2>'; while ($row = mysql_fetch_assoc($result)) { if ($last_target['targetname'] != $row['targetname']) { if ($last_target) { printf(' <table border="1" width="600"> <tr> <th>Opponent Name:</th> <th colspan="2">%s</th> </tr> <tr> <th>Wins</th> <th>Losses</th> <th>Draws</th> </tr> <tr> <td align="center">%d</td> <td align="center">%d</td> <td align="center">%d</td> </tr> <tr> <th>Last Game:</th> <td colspan="2">%s of %s: %.1f - %.1f</td> </tr> </table><br/>', $last_target['targetname'], $wins, $losses, $draws, $last_target['week'], $last_target['year'], $last_target['selected_score'], $last_target['target_score'] ); } $wins = $losses = $draws = 0; } if ($row['selected_score'] < $row['target_score']) ++$losses; elseif ($row['selected_score'] == $row['target_score']) ++$draws; else ++$wins; $last_target = $row; } ?> Any ideas on how to make the magic elvish be good??? Thank you for your time. I am running a contact form, which successfully works and sends the info, what I need help with, is when the form is submitted and the email is received this is the message: Code: [Select] Name: Name Appears Here Email: Email of client IP: 123456789 Message: Message content What I would like is to have another variable added to the email so the user whom reads it knows where the message came from, to below message for example From: Blah Here is the contact.php Code: [Select] <?php session_name("fancyform"); session_start(); $_SESSION['n1'] = rand(1,20); $_SESSION['n2'] = rand(1,20); $_SESSION['expect'] = $_SESSION['n1']+$_SESSION['n2']; $str=''; if($_SESSION['errStr']) { $str='<div class="error">'.$_SESSION['errStr'].'</div>'; unset($_SESSION['errStr']); } $success=''; if($_SESSION['sent']) { $success='<h1>Thank you!</h1>'; $css='<style type="text/css">#contact-form{display:none;}</style>'; unset($_SESSION['sent']); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Contact</title> <script type="text/javascript" src="jquery.js"></script> <style>body{background: #ededed;margin:0;padding:0;}#menu_wrap{position:relative;margin-top:20px;margin-left:auto;margin-right:auto;padding:0; padding-right:0px;width:313px;height:37px;list-style-type:none;-webkit-border-radius:20px;-moz-border-radius:20px;border-radius:20px;-webkit-box-shadow:0 1px 3px rgba(0,0,0,.2);-moz-box-shadow:0 1px 3px rgba(0,0,0,.2);box-shadow:0 1px 3px rgba(0,0,0,.2)}.button a{cursor:pointer;text-align:center;font:16px/100% Arial, Helvetica, sans-serif;font-weight:bold;position:relative;min-width:50px;height:20px;float:left;padding:10px;padding-top:8.5px;padding-bottom:8.5px;text-decoration:none;text-shadow:0 1px 1px rgba(0,0,0,.3)}.button:first-child a{-webkit-border-top-left-radius:20px;-webkit-border-bottom-left-radius:20px;-moz-border-topleft-radius:20px;-moz-border-bottomleft-radius:20px;border-top-left-radius:20;border-bottom-left-radius:20px}.Vista_Green, .Vista_Green .button a{color:#FFF;background: #9dd53a;background: -moz-linear-gradient(top, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%);background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#9dd53a), color-stop(50%,#a1d54f), color-stop(51%,#80c217), color-stop(100%,#7cbc0a));background: -webkit-linear-gradient(top, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%);background: -o-linear-gradient(top, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%);background: -ms-linear-gradient(top, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%);filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#9dd53a', endColorstr='#7cbc0a',GradientType=0 );background: linear-gradient(top, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%);}.Vista_Green .button a:hover,.Vista_Green .button a:focus,.Vista_Green .button a:active{background: #7cbc0a;background: -moz-linear-gradient(top, #7cbc0a 0%, #80c217 13%, #a1d54f 50%, #9dd53a 100%);background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#7cbc0a), color-stop(13%,#80c217), color-stop(50%,#a1d54f), color-stop(100%,#9dd53a));background: -webkit-linear-gradient(top, #7cbc0a 0%,#80c217 13%,#a1d54f 50%,#9dd53a 100%);background: -o-linear-gradient(top, #7cbc0a 0%,#80c217 13%,#a1d54f 50%,#9dd53a 100%);background: -ms-linear-gradient(top, #7cbc0a 0%,#80c217 13%,#a1d54f 50%,#9dd53a 100%);filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7cbc0a', endColorstr='#9dd53a',GradientType=0 );background: linear-gradient(top, #7cbc0a 0%,#80c217 13%,#a1d54f 50%,#9dd53a 100%);}.button:last-child a{float:left;border:none; -webkit-border-top-right-radius:20px;-webkit-border-bottom-right-radius:20px;-moz-border-radius:20px;border-top-right-radius:20px;border-bottom-right-radius:20px}</style> <br> <link rel="stylesheet" type="text/css" href="jqtransformplugin/jqtransform.css" /> <link rel="stylesheet" type="text/css" href="formValidator/validationEngine.jquery.css" /> <link rel="stylesheet" type="text/css" href="index.css" /> <?=$css?> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="jqtransformplugin/jquery.jqtransform.js"></script> <script type="text/javascript" src="formValidator/jquery.validationEngine.js"></script> <script type="text/javascript" src="script.js"></script> </head> <p align="center"> <img border="0" src="images/image6611.png"></p> </p> <ul id="menu_wrap" class="Vista_Green"><li class="button"><a href="index.php">Home</a></li><li class="button"><a href="services.php">Services</a></li><li class="button"><a href="extra.php">Extra</a></li><li class="button"><a href="#">Contact</a></li> </ul><!-- Javascript code--> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script> <script type="text/javascript">var search_input= $('.search input[type=text]');var search_input_size =120; var search_large_size = 180; var padding = 5; var shrinked = "";$(document).ready(function(){search_input.click(function(){shrink();}).focus(function(){shrink();});search_input.blur(function(){ if(shrinked=="YES")normal();});$('.button a').hover(function(){if(shrinked=="YES")normal();}); });function shrink(){if(search_input_size < search_large_size ){$('.button a').each(function(){$(this).animate({'padding-left': padding+'px','padding-right': padding+'px'},'fast');});search_input.animate({'width': search_large_size+'px'},'fast'); shrinked="YES";}return false;}function normal(){search_input.animate({'width':search_input_size+'px'},'fast'); $('.button a').animate({'padding-left':'10px','padding-right':'10px'},'fast');shrinked="";search_input.blur();return false;}</script> <body> <div id="main-container"> <div id="form-container"> <h1>Your Friendly Tree Specialist</h1> <h2>We will contact you soon.</h2> <form id="contact-form" name="contact-form" method="post" action="submit.php"> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td width="15%"><label for="name">Name</label></td> <td width="70%"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="<?=$_SESSION['post']['name']?>" /></td> <td width="15%" id="errOffset"> </td> </tr> <tr> <td><label for="email">Email</label></td> <td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td> <td> </td> </tr> <tr> <td><label for="subject">Subject</label></td> <td><select name="subject" id="subject"> <option value="" selected="selected"> - Choose -</option> <option value="Question">Question</option> <option value="Business proposal">Business proposal</option> <option value="Advertisement">Advertising</option> <option value="Other">Other</option> </select> </td> <td> </td> </tr> <tr> <td valign="top"><label for="message">Message</label></td> <td><textarea name="message" id="message" class="validate[required]" cols="35" rows="5"><?=$_SESSION['post']['message']?></textarea></td> <td valign="top"> </td> </tr> <tr> <td><label for="captcha"><?=$_SESSION['n1']?> + <?=$_SESSION['n2']?> =</label></td> <td><input type="text" class="validate[required,custom[onlyNumber]]" name="captcha" id="captcha" /></td> <td valign="top"> </td> </tr> <tr> <td valign="top"> </td> <td colspan="2"><input type="submit" name="button" id="button" value="Submit" /> <input type="reset" name="button2" id="button2" value="Reset" /> <?=$str?> <images id="loading" src="images/ajax-load.gif" width="16" height="16" alt="loading" /></td> </tr> </table> </form> <?=$success?> </div> <div class="tree-info"> </div> </div> </body> </html> Here is the submit.php Code: [Select] <?php /* config start */ $emailAddress = 'emailhere'; /* config end */ require "phpmailer/class.phpmailer.php"; session_name("fancyform"); session_start(); foreach($_POST as $k=>$v) { if(ini_get('magic_quotes_gpc')) $_POST[$k]=stripslashes($_POST[$k]); $_POST[$k]=htmlspecialchars(strip_tags($_POST[$k])); } $err = array(); if(!checkLen('name')) $err[]='The name field is too short or empty!'; if(!checkLen('email')) $err[]='The email field is too short or empty!'; else if(!checkEmail($_POST['email'])) $err[]='Your email is not valid!'; if(!checkLen('subject')) $err[]='You have not selected a subject!'; if(!checkLen('message')) $err[]='The message field is too short or empty!'; if((int)$_POST['captcha'] != $_SESSION['expect']) $err[]='The captcha code is wrong!'; if(count($err)) { if($_POST['ajax']) { echo '-1'; } else if($_SERVER['HTTP_REFERER']) { $_SESSION['errStr'] = implode('<br />',$err); $_SESSION['post']=$_POST; header('Location: '.$_SERVER['HTTP_REFERER']); } exit; } $msg= 'Name: '.$_POST['name'].'<br /> Email: '.$_POST['email'].'<br /> IP: '.$_SERVER['REMOTE_ADDR'].'<br /><br /> From: Aussie Submission<br /> Message:<br /><br /> '.nl2br($_POST['message']).' '; $mail = new PHPMailer(); $mail->IsMail(); $mail->AddReplyTo($_POST['email'], $_POST['name']); $mail->AddAddress($emailAddress); $mail->SetFrom($_POST['email'], $_POST['name']); $mail->Subject = "A new ".mb_strtolower($_POST['subject'])." from ".$_POST['name']." | contact form feedback"; $mail->MsgHTML($msg); $mail->Send(); unset($_SESSION['post']); if($_POST['ajax']) { echo '1'; } else { $_SESSION['sent']=1; if($_SERVER['HTTP_REFERER']) header('Location: '.$_SERVER['HTTP_REFERER']); exit; } function checkLen($str,$len=2) { return isset($_POST[$str]) && mb_strlen(strip_tags($_POST[$str]),"utf-8") > $len; } function checkEmail($str) { return preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $str); } ?> The form works fine, no errors just need to know how to add the extra message. I have tried adding it to the submit, but when I submit the form, I get a blank page, if I push back, it goes to the thank you message and is sent. Hopefully someone can help, thank you. Hi everyone, this is my first time in this forum and I really need to seek some help from much more experienced PHP coders. My Final Year Project requires me to create a questionnaire to collect Profiling Data from the students. However with only half a year's experience with PHP coding, we find our knowledge rather insufficient at this point. Currently we have created a simple questionnaire with a simple search engine [attached] However now we have been requested to create a questionnaire where it is able to edit, add, remove questions from the questionnaire online itself without the need to go backend. Looking at some tutorials and other posts on this forum, I realised that the "hardcoding" we did, by putting all the questions/answers in to the HTML code itself instead of pulling it out from the database in SQL will cause difficulties. Thus I have decided to build the whole survey from scratch where the questions and answers are all stored in the SQL database itself. Help needed : > How should I actually create my database? What is in my mind now is to create a database with tables as such: Questionslist (Storing questions) id, questionid, question Answerslist (Storing options for questions male,female etc.) id, questionid, option > I currently have no clue how to start creating a page where I can add/edit/remove the questions in the questionnaire. Any example on how to start? > I roughly have an idea on how to edit or remove the questions the questions, but how do I add a question with the choice of making it a TEXT option, or a RADIO BUTTON option or a LIST option and have it add that question into my table of questionlist and answerlist as well? Currently using Adobe Dreamweaver CS5 and HeidiSQL for this project. We have requested a webspace from the school itself to host this questionnaire as well. If anyone needs more infomation to be able to assist me, I would gladly provide. With Thanks, Shawn [attachment deleted by admin] I just installed this new script here http://webhost.pro/domain-check.php it's a basic domain availability tool. I am trying to make a form that can be used on any page forward to this page with the content. The page loads with this in the url webhost.pro/domain-check.php?domain=dwhs.net and will run the page. So I can make a form that just submits to that page and sends the details. I made this page for testing http://webhost.pro/test.html But no go, here is the code: <form id="search" action="/domain-check.php" method="GET"> <input type="text" name="s"> <a onClick="document.getElementById('search').submit()" class="button1">Search</a> <div class="clear"></div> </form> Thanks! |