-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
For displaying the list after an update has been made, you could look into using the same page that displays the list to also process the update. For example, you page could be modified to do the following: [*]If user clicked one of the edit links get the ID to edit make sure the ID is valid update the database, if the ID was valid If the update was successful / unsuccessful, display corresponding message to user [*]Get the list of contacts [*]Display the list of contacts Note that steps 2 and 3 happen whether or not an edit link was clicked.
-
If you're looking for how to update the database, there are many tutorials out there: https://www.google.com/search?q=update+a+mysql+database+with+php The UPDATE syntax for MySQL can be found here: http://dev.mysql.com/doc/refman/5.0/en/update.html
-
Also note that you don't need the <form> tag if you're using links.
-
Sorry, I mistyped the code. You need a name/value pair for each variable. <a href="update_script.php?id=<?php print $current_record_id; ?>">Update Current Record</a> So your code would be changed to: <TD ALIGN=CENTER ><a href="update_script.php?id=<?php print $row_Recordset1['idjudge']; ?>">Update</a></td> Of course, "id" would be whatever you want to name the variable.
-
My preference would be to use plain HTML links. <a href="update_script.php?<?php print $current_record_id; ?>">Update Current Record</a> Then on the PHP side, you could retrieve the ID with $_GET.
-
Ah yes, good point. So you should have everything you need to update individual records?
-
It doesn't look like your contact database has a primary key. First, I would recommend adding one so you can reference an individual record. A button can then be added which passes that ID to the script performing the database update.
-
Just to clarify about the security issue, try visiting your page using Firefox. When visiting the website though, change the address to: www.yourwebsiteaddress.com/yourscript.php/'><script type="text/javascript">window.location="http:/\/www.google.com/"</script><!-- Note that "www.yourwebsiteaddress.com/yourscript.php" should be changed to the URL used to access your page. If typed correctly, it should redirect you to Google.
-
The problem is that you're using double quotes inside of a double-quoted string. Try: echo " <a class='nav' href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; As for the security issues with $_SERVER['PHP_SELF'], check out some of the links provided by the following Google search: http://www.google.com/search?q=security+issues+with+php_self+in+links Note that a lot of focus seems to be placed on using PHP_SELF in forms, but there's an issue with using the variable to display things like links also. Instead of using PHP_SELF, the page's filename could be explicitly stated. echo " <a class='nav' href='your_page.php?currentpage=$nextpage'>></a> ";
-
What did the code for the next link look like when you got the error? What was the error? Also, for security reasons, you shouldn't use $_SERVER['PHP_SELF'] when displaying links.
-
You could set a $_SESSION variable. Then add a test for the variable before processing the change again.
-
A quick and dirty way is to do something like: <?php $monthTotals = array('January'=>0, 'February'=>0, 'March'=>0, 'April'=>0, 'May'=>0, 'June'=>0, 'July'=>0, 'August'=>0, 'September'=>0, 'October'=>0, 'November'=>0, 'December'=>0); $testData = array('June', 'June', 'July', 'August', 'June', 'July', 'May'); foreach($testData as $currMonth) { $monthTotals[$currMonth]++; } foreach($monthTotals as $currKey => $currTotal) { print "<div>$currKey: $currTotal</div>"; } ?>
-
Too many if isset statements, better way to handle?
cyberRobot replied to flambo's topic in PHP Coding Help
Yep, after running the above, $filter will always be set. Note that the above code is the same as: $filter = (isset($_GET["filter"])) ? $_GET["filter"] : ""; -
Too many if isset statements, better way to handle?
cyberRobot replied to flambo's topic in PHP Coding Help
Instead of duplicating the call to the filter method, you could change the code to: <?php $_GET['filter'] = (isset($_GET['filter'])) ? $_GET['filter'] : ''; $theFilter = $pageination->filter($_GET['filter']); ?> -
I just noticed the following: <?php //... echo '<td>'.$row['Email'].'</td>'; echo '<td>' '</td>'; //<--- THE NON-BREAKING SPACE CHARACTER NEEDS TO BE INSIDE THE STRING --- SHOULD BE: echo '<td> </td>'; echo '</tr>'; //... ?>
-
You're missing a semicolon after displaying the table header: <?php //... echo "<table> <tr> <td>First Name</td> <td>Last Name</td> <td>Title</td> <td>Location</td> <td>Office Phone</td> <td>Office Extention</td> <td>Mobile</td> <td>Edit</td> <td> </td> </tr> </table>" //<--- ADD SEMICOLON HERE //... ?> The while loop shouldn't have a semicolon after it: <?php //... while($row = mysql_fetch_array($result)); //<--- REMOVE SEMICOLON { //... ?> Also, as Andy-H stated, the close tag for the table should go after all the table rows. <?php //... echo "<table> <tr> <td>First Name</td> <td>Last Name</td> <td>Title</td> <td>Location</td> <td>Office Phone</td> <td>Office Extention</td> <td>Mobile</td> <td>Edit</td> <td> </td> </tr>"; while($row = mysql_fetch_array($result)) { echo '<tr>'; //... echo '</tr>'; } echo '</table>'; //... ?> For bonus points, you should also utilize the table heading tag and scope attribute. <?php //... echo "<table> <tr> <th scope='col'>First Name</th> <th scope='col'>Last Name</th> <th scope='col'>Title</th> <th scope='col'>Location</th> <th scope='col'>Office Phone</th> <th scope='col'>Office Extention</th> <th scope='col'>Mobile</th> <th scope='col'>Edit</th> <th scope='col'> </th> </tr>"; //... ?>
-
To be honest, I don't know. Since I'm not very familiar with how the code relates to the rest of the website, it's difficult to say where the $_SESSION variable needs to be set. The only thing I can say is that it needs to be set somewhere in the website where you know employee's name...which is probably on the page before getting to the form. Note that I don't have a lot of time (right now) to help with the issue. Of course, you can still post more questions / code. Maybe someone else will be able to help...or maybe I'll be able to help later.
-
NULL means that $_SESSION['emp_name'] has not been set. Since the variable isn't set, the code inside the following if statement will not execute: <?php if (isset($_SESSION['emp_name'])){ $CurrentEmpName=$_SESSION['emp_name']; } ?>
-
Sounds like you may have missed the semi-colon after the var_dump(). <?php var_dump($_SESSION['emp_name']); ?>
-
If you attempt to display $_SESSION['emp_name'] as show below, what does it display? <?php //... var_dump($_SESSION['emp_name']); //<--- ADD THIS CODE BEFORE YOUR IF STATEMENT if (isset($_SESSION['emp_name'])){ $CurrentEmpName=$_SESSION['emp_name']; } //... ?>
-
All that does is check if $_SESSION['emp_name'] has been set. The code would look more like: <?php $_SESSION['emp_name'] = $name; ?>
-
Hmm...there has to be more code somewhere. As Muddy_Funster asked, where is $_SESSION['emp_name'] being set? Note that it could have been set somewhere else on the website.
-
You'll also want to validate / sanitize the data, if you haven't done so already. For example, if a field is supposed to be a number, you could check by using something like ctype_digit(): <?php if( ctype_digit( (string) $numToTest) ) { print "Number; continue processing"; } else { print "Not a number; flag error"; } ?> If selecting one of several radio buttons in a form, make sure the value corresponds with one of the options. If the value isn't supposed to contain HTML / PHP tags, you could run strip_tags() to remove them. http://php.net/manual/en/function.strip-tags.php
-
@danielbala - Did you create the code? The script looks like it was made to gather input from multiple pages. Some access the script via $_SESSION variables, while others use $_GET variables. However, the code provided doesn't show what happens when dealing with $_POST variables. Is there more code that's not being shown?