PHP - Final Year Polytechnic Project (editable Online Questionnaire)
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] Similar TutorialsSo I have decided to do research as my project and gain something from this. But also I will have to include programming which i prefer PHP. and will be testing these for my research. Does this sound like a good project and also If it is good sound.. Where do I start?... need a starting point and then I could go on to doing it.. This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=318011.0 Hello, i have two fields. a beginning year and an ending year. How can i make new fields out of the years in between the beginning and ending years. i hope that makes sense. Hi all I`m trying to build simple quesdtionnaire with few questions and answers. i would like use arrays to do it. however i cannot figure out what is wrong with a bit i wrote thanks for help Hi everyone... I would like to implement a questionnaire/survey system that has only two Answers (Yes /No). Basically, this questionnaire system will be widely used on Mobile Phones. It will be looking something like this below: http://awardwinningfjords.com/2009/06/16/iphone-style-checkboxes.html Lets say a user selects a response as No (Using the above slider button for a question). That response should be recorded in the database with User Details + Time Stamp. Also, I would like to generate a report for each question (Responses of Multiple Users) and a report at a User Level for the entire questionnaire/survey (s). Can some one guide me the fastest & easiest way to achieve this? I'm a new learner of PHP. Regards Sandeep I, 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 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. 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, I am trying to create a system where the user can just edit the page online. I have tried to do this using the <!-- EDITABLE --> tag. My system logs in fine and displays the pages that can be edited, however when I click on the page to edit it it doesn't provide the editable region in a text area to be able to change it which it should do. This is the section of code that should make the user able to change the text: if ($_SESSION['username']=='login') { if (isset($_REQUEST['file'])) { $fc = file_get_contents($_REQUEST['file']); $text = explode("<!-- EDITABLE -->",$fc); echo "<form method='post' action=''><textarea name='content'>$text[1]</textarea>"; echo "<p><input type='hidden' name='file' value='".$_REQUEST['file']."' /><input name='submitUpdate' type='submit' value='Update Page'></form>"; } else { echo "<p align='center'> <a href='index.html'>Home Page</a><br/> <a href='contact_us.html'>Contact Us</a><br/> <br/> <em>Click on the links above to edit the files.</em><br/> <a href='logout'>logout</a></p>"; } } The section of code that can be edited in each file is coded like this: <div class='main'> <!-- EDITABLE --> Contents written here can be edited <!-- EDITABLE --> </div> Anybody got any ideas as its giving me no error messages and I can't see whats wrong with the code. Thanks in advance I'm useing a simple HTML drop-down list box. But now I want to be able to and an editable drop-down box so that if the particular item in the drop-down is not changed it won't update the database. But if a new value is selected it will update the DB with the new value.
I am not clear on a couple of things. should the valuse of the drop down be in a seperate DB table. And then the script to change the new value or keep the old.
I've googled this and can't seem to find a workable solution.
Thanks in advance,
How do you display non-editable data that is part of a larger form? For instance, I have an "Add a Comment" for with... =========================== * Article Title (non-editable) * Name (non-editable) * Comment (editable) Submit button =========================== Do I just make a Form with one Input field for the editable field?! And then make the first two "fields" stylized <p> tags?? Debbie Hello
I am using fpdf to generate pdf files based on certain csv files. Now the client wants certain fields of the generated pdf file to be 'interactive' .
Is this possible ? Googling about editable (interactive pdf's) only confused me . any help ?
btw by interactive I mean fields that can be typed into directly by the client and then saved into the pdf .
Hello, I have encountered a problem and I am not even sure it's stricty PHP-related. The problem is with website I want to migrate to a better hosting provider and I also have to edit the code to make it PHP 5 compatible. I have a news editing panel that uses FCKEditor. There are 3 fields: date, news title, and news text. The first two are OK, but the textarea is empty and non-editable, i.e. I cannot click in it to put the cursor inside. The problem only exists on my local Wampserver (PHP 5.3.0). When I upload all the files to the old hosting server (PHP 5.2.5) the textarea is editable. Here is the code that loads the news editing page: <?php class page extends admin{ function page(){ if(isset($_GET['do'])) { if($_GET['do']=='del'){ mysql_query("DELETE FROM news WHERE id = '$_GET[id]'"); mysql_query("DELETE FROM news_text WHERE parent = '$_GET[id]'"); $this->loc("?nav=news"); } if(!empty($_POST['date'])){ $sql="UPDATE news SET ".$this->post_insert(array("date"))." WHERE id = '$_GET[id]'"; mysql_query($sql); echo $sql; $parent=$_GET['id']; //insert lang values $this->update_langs("news_text",array("name","content"),$parent); $this->loc(); } } } // Sub menu Buttos var $sub_menus=array( array("Списък новини","news"), array("Добави новина","add_news") ); //Sub menu generation function sub_menu(){ for($i=0;$i<sizeof($this->sub_menus);$i++){ echo "<li><a href=\"?nav=".$this->sub_menus[$i][1]."\">".$this->sub_menus[$i][0]."</a></li>"; } } // Language form template function lang_form($name,$id){ echo ' <fieldset> <legend>'.$name.'</legend> <div class="line"><label>Име: </label> <input name="name_'.$id.'" class="text" style="width:450px;" value="'.$this->get_sql_value("SELECT * FROM news_text WHERE parent='$_GET[id]' AND lang='$id'","name").'" type="text" /> </div> <div class="line"><label>Съдържание: </label></div>'; $oFCKeditor = new FCKeditor('content_'.$id); $oFCKeditor->BasePath = 'includes/fckeditor/'; $oFCKeditor->Height= '500px'; $oFCKeditor->Value= $this->get_sql_value("SELECT * FROM news_text WHERE parent = '$_GET[id]' AND lang='$id'","content"); $oFCKeditor->Create(); echo' </fieldset>'; } } $p=new page(); ?> <div id="left"> <ul> <li><h1>Опции:</h1></li> <?php echo $p->sub_menu(); ?> </ul> </div> <div id="center"> <h1>Amalipe.com / Администрация / Новини / Редакция на новина</h1> <form name="add" id="add" action="" method="post"> <fieldset> <legend>Основна информация</legend> <div class="line"><label>Дата: </label> <input name="date" class="text" type="text" value="<?php echo $p->get_value("news","date"); ?>" /></div> </fieldset> <?php $p->lang_forms(); ?> <input value="Промени" class="btn" type="submit" /> </form> </div> The encoded characters you see in the code are Cyrillic names. At first I thought this had something to do with the FCKEditor version so I upgraded it to the last one (FCKeditor_2.6.6) but nothing changed. On my local Wampserver I have two PHP versions - 5.2.9-2 and 5.3.0 - neither works. I have also added 5.2.5 to see if this changes anything but no, it doesn't - the textarea is still empty and non-editable. I hope I can get some help! I am using Dreamweaver CS4 to build a website. On my contact page, I made a form with spry validation. I used a tutvid tutorial to learn a simple form handler script (I'm a complete newb at PHP) and everything works great. The only problem I'm having is, in my Dreamweaver template, I have an editable region that has the form. When the user clicks to submit the form, a new html page opens up that looks nothing like my website. What I'm trying to accomplish is having the form disappear and be replaced in the same editable region with my "thank you" message. This way, the user just submits, the form disappears, and they get a thank you message on the same page, in the same place where the form was. Here is the form code: Code: [Select] <form id="frmContact" name="frmContact" method="post" action="contact_form.php"> <fieldset><legend>Submit a question or comment...</legend> <p> <label for="name">Name:</label> <span id="spryName"> <input type="text" name="name" id="name" /> <span class="textfieldRequiredMsg">Name is required.</span><span class="textfieldMinCharsMsg">Must have at least 3 characters.</span><span class="textfieldMaxCharsMsg">Must not exceed 20 characters.</span></span></p> <p> <label for="email">Email:</label> <span id="spryPassword"> <input type="text" name="email" id="email" tabindex="10" /> <span class="textfieldRequiredMsg">Email address is required.</span><span class="textfieldInvalidFormatMsg">Not a valid email address.</span><span class="textfieldMinCharsMsg">Not a valid email address.</span><span class="textfieldMaxCharsMsg">Not a valid email address.</span></span></p> <p> <label id="message" for="question">Please tell us how we can help you:</label><br /> <span id="spryText"> <textarea name="question" id="question" cols="45" rows="5" tabindex="20"></textarea><br /> <span class="textareaRequiredMsg">A question or comment is required.</span><span class="textareaMinCharsMsg">Must have 16 characters minimum</span><span class="textareaMaxCharsMsg">Must not exceed 500 characters.</span></span></p> <p> <input type="submit" name="submit" id="submit" value="Submit" tabindex="30" /> </p> </fieldset> </form> Here is the PHP script: <?php /* Subject and Email variables */ $emailSubject = 'Contact Form Response'; $webMaster = 'centerline.computers@gmail.com'; /* Gather Data variables */ $nameField = $_POST['name']; $emailField = $_POST['email']; $questionField = $_POST['question']; $body = <<<EOD <br><hr><br> Name: $nameField <br> Email: $emailField <br> Message: $questionField <br> EOD; $headers = "From: $emailField\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <html><body> <h2>Thank you for submitting.</h2> <p>We will get back to you as soon as possible.</p> </body> </html> EOD; echo "$theResults"; ?> Thanks for any help you might have for me! Hello All, Have another problem want to make the fields editable, i have tried in several ways but it's not helping if some one can help me out on this, i have tried contents editable = "true" but not helpful at all below is the code: Please advise what and where needs to be added to make the fields editable except date fields. <?php session_start(); error_reporting(0); include('includes/dbconnection.php'); if (strlen($_SESSION['cvmsaid']==0)) { header('location:logout.php'); } else{ if(isset($_POST['submit'])) { $eid=$_GET['editid']; $remark=$_POST['remark']; $fullname=$_POST['fullname']; $query=mysqli_query($con,"update tblsupvisitor set remark='$remark',fullname-'$fullname' where ID='$eid'"); if ($query) { $msg="Visitors Remark has been Updated."; } else { $msg="Something Went Wrong. Please try again"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <!-- Required meta tags--> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content="au theme template"> <meta name="author" content="Hau Nguyen"> <meta name="keywords" content="au theme template"> <!-- Title Page--> <title>CVSM Visitors Forms</title> <!-- Fontfaces CSS--> <link href="css/font-face.css" rel="stylesheet" media="all"> <link href="vendor/font-awesome-5/css/fontawesome-all.min.css" rel="stylesheet" media="all"> <link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all"> <link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all"> <!-- Bootstrap CSS--> <link href="vendor/bootstrap-4.1/bootstrap.min.css" rel="stylesheet" media="all"> <!-- Vendor CSS--> <link href="vendor/animsition/animsition.min.css" rel="stylesheet" media="all"> <link href="vendor/bootstrap-progressbar/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet" media="all"> <link href="vendor/wow/animate.css" rel="stylesheet" media="all"> <link href="vendor/css-hamburgers/hamburgers.min.css" rel="stylesheet" media="all"> <link href="vendor/slick/slick.css" rel="stylesheet" media="all"> <link href="vendor/select2/select2.min.css" rel="stylesheet" media="all"> <link href="vendor/perfect-scrollbar/perfect-scrollbar.css" rel="stylesheet" media="all"> <!-- Main CSS--> <link href="css/theme.css" rel="stylesheet" media="all"> </head> <body class="animsition"> <div class="page-wrapper"> <!-- HEADER MOBILE--> <?php include_once('includes/sidebar-Supp.php');?> <!-- END HEADER MOBILE--> <!-- MENU SIDEBAR--> <!-- END MENU SIDEBAR--> <!-- PAGE CONTAINER--> <div class="page-container"> <!-- HEADER DESKTOP--> <?php include_once('includes/header-supp.php');?> <!-- HEADER DESKTOP--> <!-- MAIN CONTENT--> <div class="main-content"> <div class="section__content section__content--p30"> <div class="container-fluid"> <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-header"> <strong>Visitor</strong> Details </div> <div class="card-body card-block"> <p style="font-size:16px; color:red" align="center"> <?php if($msg){ echo $msg; } ?> </p> <?php $eid=$_GET['editid']; $ret=mysqli_query($con,"select * from tblsupvisitor where ID='$eid'"); $cnt=1; while ($row=mysqli_fetch_array($ret)) { ?><table border="1" class="table table-bordered mg-b-0"> <tr> <th>Full Name</th> <td><?php echo $row['FullName'];?></td> </tr> <tr> <th>Qatar ID #</th> <td><?php echo $row['IDNO'];?></td> </tr> <tr> <th>Vehicle #</th> <td><?php echo $row['vno'];?></td> </tr> <tr> <th>No of Persons</th> <td><?php echo $row['noopaxs'];?></td> </tr> <tr> <th>Address</th> <td><?php echo $row['Address'];?></td> </tr> <tr> <th>Whom to Meet</th> <td><?php echo $row['WhomtoMeet'];?></td> </tr> <tr> <th>Deptartment</th> <td><?php echo $row['Deptartment'];?></td> </tr> <tr> <th>Reason to Meet</th> <td><?php echo $row['ReasontoMeet'];?></td> </tr> <tr> <th>Vistor Entring Time</th> <td><?php echo $row['EnterDate'];?></td> </tr> <?php if($row['remark']==""){ ?> <form method="post"> <tr> <th>Outing Remark :</th> <td> <textarea name="remark" placeholder="" rows="12" cols="14" class="form-control wd-450" required="true"></textarea></td> </tr> <tr align="center"> <td colspan="2"><button type="submit" name="submit" class="btn btn-primary btn-sm">Update</button></td> </tr> </form> <?php } else { ?> <tr> <th>Outing Remark </th> <td><?php echo $row['remark']; ?></td> </tr> <tr> <th>Out Time</th> <td><?php echo $row['outtime']; ?> </td> <?php } ?> </tr> </table> </div> </div> </div> </div> <?php include_once('includes/footer.php');?> </div> </div> </div> </div> <!-- Jquery JS--> <script src="vendor/jquery-3.2.1.min.js"></script> <!-- Bootstrap JS--> <script src="vendor/bootstrap-4.1/popper.min.js"></script> <script src="vendor/bootstrap-4.1/bootstrap.min.js"></script> <!-- Vendor JS --> <script src="vendor/slick/slick.min.js"> </script> <script src="vendor/wow/wow.min.js"></script> <script src="vendor/animsition/animsition.min.js"></script> <script src="vendor/bootstrap-progressbar/bootstrap-progressbar.min.js"> </script> <script src="vendor/counter-up/jquery.waypoints.min.js"></script> <script src="vendor/counter-up/jquery.counterup.min.js"> </script> <script src="vendor/circle-progress/circle-progress.min.js"></script> <script src="vendor/perfect-scrollbar/perfect-scrollbar.js"></script> <script src="vendor/chartjs/Chart.bundle.min.js"></script> <script src="vendor/select2/select2.min.js"> </script> <!-- Main JS--> <script src="js/main.js"></script> </body> </html> <!-- end document--> <?php } ?> <?php } ?>
Any help will be much appreciated.
Kind Regards, Naveed. Edited July 30, 2020 by Naveed786I 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! Why does this work: $dateAllowedSelect = date('Y') -18; But this doesn't: $dateAllowedSelect = date('Y') +5; I nee to get the current year plus 2010 - 2015 in a select box. Thank you. |