jamesxg1 Posted March 10, 2010 Share Posted March 10, 2010 Hiya Peeps! I have this echo'ed in a script. $("form#addjob").submit(function(){ var company = $("input#company").val(); var location = $("input#location").val(); var industry = $("input#industry").val(); var jobtype = $("select#jobtype").val(); var experience = $("input#experience").val(); var education = $("input#education").val(); var careerlevel = $("input#careerlevel").val(); var salary = $("input#salary").val(); var title = $("input#title").val(); var description = $("textarea#description").val(); var empname = $("input#empname").val(); var empphone = $("input#empphone").val(); $.post("./system/core/runactions.php?cmd=addjob", { company: company, location: location, industry: industry, jobtype: jobtype, experience: experience, education: education, careerlevel: careerlevel, salary: salary, title: title, description: description, empname: empname, emphone: emphone }, function(data) { var data = data; $("span#feedback").html(data); }); return false; }); Its not working past var empphone = $("input#empphone").val(); Can anyone see why ? Many thanks James. Link to comment https://forums.phpfreaks.com/topic/194713-echo-problem-i-think/ Share on other sites More sharing options...
trq Posted March 10, 2010 Share Posted March 10, 2010 I have this echo'ed in a script. Can we see your actual code then? Link to comment https://forums.phpfreaks.com/topic/194713-echo-problem-i-think/#findComment-1024000 Share on other sites More sharing options...
jamesxg1 Posted March 10, 2010 Author Share Posted March 10, 2010 Ok, runactions.php <?php session_start(); include 'mysql.php'; $mysql = new mysql(); $mysql->connect(); include 'actions.php'; $action = new actions(); $action->approvalValues(); switch($_GET['cmd']): case viewjobs: echo $action->listJobs(); break; case delete: echo '<center>' . $action->deleteJob($_GET['id']) . '</center>'; break; case addJob: echo $action->newJob($_POST['company'], $_POST['location'], $_POST['industry'], $_POST['jobtype'], $_POST['experience'], $_POST['education'], $_POST['careerlevel'], $_POST['salary'], $_POST['description'], $_POST['title'], $_POST['empname'], $_POST['empphone']); break; case editJob: echo $action->editJob($_POST['jid'], $_POST['company'], $_POST['location'], $_POST['industry'], $_POST['jobtype'], $_POST['experience'], $_POST['education'], $_POST['careerlevel'], $_POST['salary'], $_POST['description'], $_POST['title'], $_POST['empname'], $_POST['empphone']); break; endswitch; ?> actions.php <?php session_start(); class actions { private $jobID; private $company; private $location; private $industry; private $jobtype; private $experience; private $education; private $careerlevel; private $salary; private $description; private $title; private $empname; private $empphone; function approvalValues() { $approval = "SELECT * FROM `settings`"; $runapproval = mysql_query($approval); if($runapproval): while($app = mysql_fetch_assoc($runapproval)): $this->editapproval = $app['approvaledit']; $this->addapproval = $app['approvaladd']; $this->deleteapproval = $app['approvaldelete']; endwhile; else: echo 'Failed to complete your requested action, please contact support!'; exit; endif; } function truncate($string, $length) { settype($string, 'string'); settype($length, 'integer'); for($a = 0; $a < $length AND $a < strlen($string); $a++): $output .= $string[$a]; endfor; return($output); } function listJobs() { $sid = mysql_real_escape_string(trim(addslashes($_SESSION['id']))); $susername = mysql_real_escape_string(trim(addslashes($_SESSION['username']))); echo '<script> $("span#edit").hide(); $("span#add").hide(); $("a#delete").click(function() { var delid = $(this).attr("class"); $("span#feedback").empty().load("./system/core/runactions.php?cmd=delete&id=" + delid); }); $("a#edit").click(function() { var eid = $(this).attr("class"); $("span#edit").slideDown("slow").show(); $("input#jid").attr("value", eid); $("span#add").hide(); }); $("form#editjob").submit(function() { var company = $("input#company").val(); var location = $("input#location").val(); var industry = $("input#industry").val(); var jobtype = $("select#jobtype").val(); var experience = $("input#experience").val(); var education = $("input#education").val(); var careerlevel = $("input#careerlevel").val(); var salary = $("input#salary").val(); var title = $("input#title").val(); var description = $("textarea#description").val(); var empname = $("input#empname").val(); var empphone = $("input#empphone").val(); var jid = $("input#jid").val(); $.post("./system/core/runactions.php?cmd=editJob", { company: company, location: location, industry: industry, jobtype: jobtype, experience: experience, education: education, careerlevel: careerlevel, salary: salary, title: title, description: description, empname: empname, emphone: emphone, jid: jid }, function(data) { var datas = data; $("span#feedback").html(datas); }); return false; }); $("form#addjob").submit(function(){ var company = $("input#acompany").val(); var location = $("input#alocation").val(); var industry = $("input#aindustry").val(); var jobtype = $("select#ajobtype").val(); var experience = $("input#aexperience").val(); var education = $("input#aeducation").val(); var careerlevel = $("input#acareerlevel").val(); var salary = $("input#asalary").val(); var title = $("input#atitle").val(); var description = $("textarea#adescription").val(); var empname = $("input#aempname").val(); var empphone = $("input#aempphone").val(); $.post("./system/core/runactions.php?cmd=addJob", { company: company, location: location, industry: industry, jobtype: jobtype, experience: experience, education: education, careerlevel: careerlevel, salary: salary, title: title, description: description, empname: empname, emphone: emphone }, function(data) { alert(data); }); return false; }); $("input#addjob").click(function() { $("span#add").show(); $("span#edit").hide(); }); </script> <span id="feedback"></span><p align="right"><input type="submit" id="addjob" class="button" value="New Job"><table cellpadding="0" cellspacing="0" border="0" class="Box-table" > <thead> <tr> <th class="date" scope="col">Title</th> <th scope="col">Description</th> <th scope="col">Location</th> <th scope="col">Type</th> <th scope="col">Salary</th> <th scope="col">Controls</th> </tr> </thead> <tbody>'; $sql = "SELECT * FROM `jobs` WHERE `oid` = '$sid' AND `username` = '$susername'"; $run = mysql_query($sql); if($run): if(mysql_num_rows($run) > 0): while($job = mysql_fetch_assoc($run)): $id = $job['id']; $title = $job['title']; $description = $job['description']; $location = $job['location']; $type = $job['jobtype']; $salary = $job['salary']; $jobid = $job['id']; $delete = $job['delete']; $taken = $job['taken']; endwhile; echo '<tr class="odd"> <td class="date">' . $this->truncate($title, '20') . '</td> <td>' . $this->truncate($description, '15') . '</td> <td>' . $this->truncate($location, '15') . '</td> <td>' . $type . '</td> <td>£' . $salary . '</td>'; if($delete == 1): echo '<td>DELETED</td>'; elseif ($taken == 1): echo '<td>TAKEN</TD>'; else: echo '<td><a href="#" id="delete" class="' . $id . '"><img src="assets/images/delete.jpg" width="15" height="15"></a><a href="#" id="edit" class="' . $id . '"><img src="assets/images/edit.png" width="15" height="15"></a></td>'; endif; echo '</tr> </tbody> </table> <style> .feedbackform{ padding: 5px; } div.fieldwrapper{ width: 550px; /*width of form rows*/ overflow: hidden; padding: 5px 0; } div.fieldwrapper label.styled{ /* label elements that should be styled (left column within fieldwrapper DIV) */ float: left; width: 150px; /*width of label (left column)*/ text-transform: capitalized; border-bottom: 1px solid blue; margin-right: 15px; /*spacing with right column*/ } div.fieldwrapper div.thefield{ /* DIV that wraps around the actual form fields (right column within fieldwrapper DIV) */ float: left; margin-bottom: 10px; /* space following the field */ } div.fieldwrapper div.thefield input[type="text"]{ /* style for INPUT type="text" fields. Has no effect in IE7 or below! */ width: 250px; } div.fieldwrapper div.thefield input[type="password"]{ /* style for INPUT type="text" fields. Has no effect in IE7 or below! */ width: 250px; } div.fieldwrapper div.thefield textarea{ /* style for TEXTAREA fields. */ width: 300px; height: 150px; } </style> <span id="add"> <form id="addjob" action="#" method="post" class="feedbackform"> <hr></hr> <div class="fieldwrapper"> <label for="company" class="styled">Company:</label> <div class="thefield"> <input id="acompany" name="company" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="Location" class="styled">Location:</label> <div class="thefield"> <input id="alocation" name="location" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="industry" class="styled">Industry:</label> <div class="thefield"> <input id="aindustry" name="industry" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="jobtype" class="styled">Job Type:</label> <div class="thefield"> <select id="ajobtype" name="jobtype"> <option value="Full Time">Full Time</option> <option value="Part Time">Part Time</option> </select> </div> </div> <div class="fieldwrapper"> <label for="experience" class="styled">Experience:</label> <div class="thefield"> <input id="aexperience" name="experience" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="education" class="styled">Education:</label> <div class="thefield"> <input id="aeducation" name="education" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="careerlevel" class="styled">Career Level:</label> <div class="thefield"> <input id="acareerlevel" name="careerlevel" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="salary" class="styled">Salary:</label> <div class="thefield"> <input id="asalary" name="salary" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="title" class="styled">Title:</label> <div class="thefield"> <input id="atitle" name="title" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="description" class="styled">Description:</label> <div class="thefield"> <textarea id="adescription" name="description"></textarea> </div> </div> <div class="fieldwrapper"> <label for="empname" class="styled">Employer Name:</label> <div class="thefield"> <input id="aempname" name="empname" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="empphone" class="styled">Employer Phone:</label> <div class="thefield"> <input id="aempphone" name="empphone" type="text" maxlength="255" value=""/> </div> </div> <input type="submit" id="asubmit" name="submit" value="Submit" class="button"> </form> </span> <span id="edit"> <form id="editjob" action="#" method="post" class="feedbackform"> <hr></hr> <div class="fieldwrapper"> <label for="company" class="styled">Company:</label> <div class="thefield"> <input id="company" name="company" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="Location" class="styled">Location:</label> <div class="thefield"> <input id="location" name="location" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="industry" class="styled">Industry:</label> <div class="thefield"> <input id="industry" name="industry" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="jobtype" class="styled">Job Type:</label> <div class="thefield"> <select id="jobtype" name="jobtype"> <option value="Full Time">Full Time</option> <option value="Part Time">Part Time</option> </select> </div> </div> <div class="fieldwrapper"> <label for="experience" class="styled">Experience:</label> <div class="thefield"> <input id="experience" name="experience" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="education" class="styled">Education:</label> <div class="thefield"> <input id="education" name="education" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="careerlevel" class="styled">Career Level:</label> <div class="thefield"> <input id="careerlevel" name="careerlevel" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="salary" class="styled">Salary:</label> <div class="thefield"> <input id="salary" name="salary" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="title" class="styled">Title:</label> <div class="thefield"> <input id="title" name="title" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="description" class="styled">Description:</label> <div class="thefield"> <textarea id="description" name="description"></textarea> </div> </div> <div class="fieldwrapper"> <label for="empname" class="styled">Employer Name:</label> <div class="thefield"> <input id="empname" name="empname" type="text" maxlength="255" value=""/> </div> </div> <div class="fieldwrapper"> <label for="empphone" class="styled">Employer Phone:</label> <div class="thefield"> <input id="empphone" name="empphone" type="text" maxlength="255" value=""/> </div> </div> <input type="hidden" name="jid" id="jid" value=""> <input type="submit" id="submit" name="submit" value="Submit" class="button"> </form> </span>'; else: echo '<tr class="odd"> <td class="date">No Records Found</td> <td>No Records Found</td> <td>No Records Found</td> <td>No Records Found</td> <td>No Records Found</td> <td>No Records Found</td> </tr> </tbody> </table>'; endif; else: echo '<tr class="odd"> <td class="date">Error</td> <td>Error</td> <td>Error</td> <td>Error</td> <td>Error</td> <td>Error</td> </tr> </tbody> </table>'; endif; } function newJob($company, $location, $industry, $jobtype, $experience, $education, $careerlevel, $salary, $description, $title, $empname, $empphone) { $company = mysql_real_escape_string(trim(addslashes($company))); $loaction = mysql_real_escape_string(trim(addslashes($loaction))); $industrty = mysql_real_escape_string(trim(addslashes($industry))); $jobtype = mysql_real_escape_string(trim(addslashes($jobtype))); $experience = mysql_real_escape_string(trim(addslashes($experience))); $education = mysql_real_escape_string(trim(addslashes($education))); $careerlevel = mysql_real_escape_string(trim(addslashes($careerlevel))); $salary = mysql_real_escape_string(trim(addslashes($salary))); $description = mysql_real_escape_string(trim(addslashes($description))); $title = mysql_real_escape_string(trim(addslashes($title))); $empname = mysql_real_escape_string(trim(addslashes($empname))); $empphone = mysql_real_escape_string(trim(addslashes($empphone))); $sid = mysql_real_escape_string(trim(addslashes($_SESSION['id']))); $susername = mysql_real_escape_string(trim(addslashes($_SESSION['username']))); if(!isset($company) OR !isset($location) OR !isset($industry) OR !isset($jobtype) OR !isset($experience) OR !isset($education) OR !isset($careerlevel) OR !isset($salary) OR !isset($description) OR !isset($title) OR !isset($empphone) OR !isset($empname) OR empty($company) OR empty($loaction) OR empty($industry) OR empty($jobtype) OR empty($experience) OR empty($education) OR empty($careerlevel) OR empty($salary) OR empty($description) OR empty($title) OR empty($empname) OR empty($empphone) OR strlen($company) > 100 OR strlen($loaction) > 150 OR strlen($industry) > 100 OR strlen($jobtype) > 80 OR strlen($experience) > 60 OR strlen($education) > 200 OR strlen($careerlevel) > 100 OR strlen($salary) > 10 OR strlen($description) > 250 OR strlen($title) > 60 OR strlen($empname) > 100 OR strlen($empphone) > 12): return 'Failed. Missing, incorrect or empty inputs detected.'; else: $newID = "SELECT `id` FROM `jobs` ORDER BY `id` DESC LIMIT 1"; $getID = mysql_query($newID); if($getID): while($nid = mysql_fetch_assoc($getID)): $id = $nid['id']; endwhile; if($id == 0): $id = 1; endif; else: return 'Failed to complete your request to open a new job, please contact support.'; endif; if($this->addapproval == 1): $approval = 0; elseif ($this->addapproval == 0): $approval = 1; endif; $addnew = "INSERT INTO `jobs` (`id`, `company`, `location`, `industry`, `jobtype`, `experience`, `education`, `careerlevel`, `salary`, `description`, `title`, `employername`, `employerphone`, `approval`, `taken`, `delete`, `username`, oid`) VALUES('$id', '$company', '$location', '$jobtype', '$experience', '$education', '$careerlevel', '$salary', '$description', '$title, '$empname', '$empphone', '$approval', '0', '0', '$susername', '$sid')"; $runaddnew = mysql_query($addnew); if($runaddnew): return 'Job successfully posted.'; else: return 'Failed to complete you request to open a new job, please contact support or try again.'; endif; endif; } function editJob($jobID, $company, $location, $industry, $jobtype, $experience, $education, $careerlevel, $salary, $description, $title, $empname, $empphone) { $jobID = mysql_real_escape_string(trim(addslashes($jobID))); $company = mysql_real_escape_string(trim(addslashes($company))); $loaction = mysql_real_escape_string(trim(addslashes($loaction))); $industrty = mysql_real_escape_string(trim(addslashes($industry))); $jobtype = mysql_real_escape_string(trim(addslashes($jobtype))); $experience = mysql_real_escape_string(trim(addslashes($experience))); $education = mysql_real_escape_string(trim(addslashes($education))); $careerlevel = mysql_real_escape_string(trim(addslashes($careerlevel))); $salary = mysql_real_escape_string(trim(addslashes($salary))); $description = mysql_real_escape_string(trim(addslashes($description))); $title = mysql_real_escape_string(trim(addslashes($title))); $empname = mysql_real_escape_string(trim(addslashes($empname))); $empphone = mysql_real_escape_string(trim(addslashes($empphone))); if(!isset($jobID) OR !isset($company) OR !isset($location) OR !isset($industry) OR !isset($jobtype) OR !isset($experience) OR !isset($education) OR !isset($careerlevel) OR !isset($salary) OR !isset($description) OR !isset($title) OR !isset($empphone) OR !isset($empname) OR empty($jobID) OR empty($company) OR empty($loaction) OR empty($industry) OR empty($jobtype) OR empty($experience) OR empty($education) OR empty($careerlevel) OR empty($salary) OR empty($description) OR empty($title) OR empty($empname) OR empty($empphone) OR strlen($company) > 100 OR strlen($loaction) > 150 OR strlen($industry) > 100 OR strlen($jobtype) > 80 OR strlen($experience) > 60 OR strlen($education) > 200 OR strlen($careerlevel) > 100 OR strlen($salary) > 10 OR strlen($description) > 250 OR strlen($title) > 60 OR strlen($empname) > 100 OR strlen($empphone) > 12): echo 'Failed. Missing, incorrect or empty inputs detected.'; exit; else: $getapp = "SELECT `approved` FROM `jobs` WHERE `id` = '$jobID' LIMIT 1"; $rungetapp = mysql_query($getapp); if($rungetapp): while($app = mysql_fetch_assoc($rungetapp)): $app = $app['approval']; endwhile; else: echo 'Failed to complete your action to edit/update one of your existing job posts.'; exit; endif; if($app == 1): if($this->editapproval == 1): $approval = 0; elseif ($this->editapproval == 0): $approval = 1; endif; else: $approval = 0; endif; $updatejob = "UPDATE `jobs` SET `company` = '$company', `location` = '$loaction', `industry` = '$industry', `jobtype` = '$jobtype', `experience` = '$experience', `education` = '$education', `careerlevel` = '$careerlevel', `salary` = '$salary', `description` = '$description', `title` = '$title', `employername` = '$empname', `employerphone` = '$empphone', `approval` = '$approval' WHERE `id` = '$jobID'"; $runupdate = mysql_query($updatejob); if($runupdate): echo 'Job successfully updated.'; else: echo 'Failed to complete your action to edit/update one of your existing job posts.'; exit; endif; endif; } function deleteJob($jobID) { $jobID = mysql_real_escape_string(trim(addslashes($jobID))); if(!isset($jobID) OR empty($jobID) OR strlen($jobID) > 11): echo 'Failed. Incorrect job detected.'; exit; else: if($this->deleteapproval == 1): $del = "UPDATE `jobs` SET `delete` = '1' WHERE `id` = '$jobID'"; elseif ($this->deleteapproval == 0): $del = "DELETE FROM `jobs` WHERE `id` = '$jobID' LIMIT 1"; endif; $rundel = mysql_query($del); if($rundel): echo 'Job successfully deleted.'; exit; else: echo 'Failed to complete your request to delete a job post, please contact support or try again.'; exit; endif; endif; } } ?> Many thanks James. Link to comment https://forums.phpfreaks.com/topic/194713-echo-problem-i-think/#findComment-1024007 Share on other sites More sharing options...
trq Posted March 10, 2010 Share Posted March 10, 2010 I don't see anything syntactically incorrect. its a terrible method of writing out html though especially considering its within a class. Link to comment https://forums.phpfreaks.com/topic/194713-echo-problem-i-think/#findComment-1024055 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.