Jump to content

NathanLedet

Members
  • Posts

    102
  • Joined

  • Last visited

    Never

Everything posted by NathanLedet

  1. wow yesss indeed great info. I really appreciate you taking the time to explain that bookmarked this thread and will be spending some time here for sure
  2. It can't be invoked by the client code. Example: class PrivateExample { private $msg = "Hello!"; public function __construct() {} private function getMsg() { return $this->msg; } } $example = new PrivateExample(); $msg = $example->getMsg(); // WON'T WORK Private functions are typically used as bookkeeping functions for the objects in which they reside. That, or in breaking down a complex public function into smaller parts that shouldn't be accessed directly by the world at large. OK I think I'm following you on this. In other words, private functions are functions only someone running Administrator codes can access - meaning, if I'm logged into my admin panel, then I have access to those Private functions? er am I off base here? Thanks
  3. When you're working in OOP and you have a private function, what exactly is "private" about it?
  4. OK... tinkered around with the code a little bit and this code here works. I appreciate you help F1Fan, and I apologize for not being clear. My original code in my first post had nothing to do with the result, and therefore $sel_page makes no difference for($count=1; $count <= $page_count+1; $count++){ echo "<option value=\"{$count}\" "; if ($count == $page_count+1){ echo " selected=\"selected\""; } echo ">{$count}</option>"; }
  5. functions.php function get_all_pages(){ global $conn; $query = "SELECT * FROM pages ORDER BY position ASC"; $page_set = mysql_query($query, $conn); confirm_query($page_set); return $page_set; } add_page.php - Form $page_set = get_all_pages(); $page_count = mysql_num_rows($page_set); for($count=1; $count <= $page_count+1; $count++){ echo "<option value=\"{$count}\">{$count}</option>"; }
  6. Yes let me gather it up. but I don't think I was clear enough - sorry about that. The code I posted does work. It works whenever I EDIT the page. It properly displays the selected position. What I am trying to do is re-structure that code that I already have and make it so that when I'm ADDING a page, it automatically chooses the last available position. So, if I have 3 pages, I want that script to display and have already selected "4" in the drop down menu.
  7. It's set elsewhere in the page and returns a number from the database. that number is the position: 1, 2, 3 etc. I dunno... Ask Kevin Skoglund...I'm following his lessons.
  8. I'm working on a small CMS and I've been following the tutorials at Lynda.com. When I'm on the page to Add a Page, I want to set its position (the order), so I have a drop down list which counts the number of records inside the database, and then adds 1 (if I have 3 entries, I want "4" to be highlighted so it will automatically be put in the last position) The code I currently have will count the rows, and then select the position it's currently in: $page_count = mysql_num_rows($page_set); for($count=1; $count <= $page_count+1; $count++){ echo "<option value=\"{$count}\""; if ($sel_page['position'] == $count){ echo " selected"; } echo ">{$count}</option>"; } I want to modify that code so that when I'm adding a new entry, it automatically chooses the last available option. Thanks for the help
  9. where is this tutorial? As a noob myself, I often forget the simplest of things... database connections and queries being one of those many things. This tutorial I find very helpful in reminding me of some basic things: http://www.php-mysql-tutorial.com
  10. thanks. So how would a foreign key come into play when performing queries?
  11. I have a script written where people can add addresses to their address book, and then when they are sending an e-mail, they go through the list of e-mail addresses and check each e-mail they want to send the e-mail to. When they click "Send", it sends them to another page, which dispatches the e-mail and gives confirmation. The problem is if it sends to more than one person, the person that is #3 on the list will receive the message 3 times (one right under the other, not 3 different e-mails) I was sent an e-mail the other day, and I was 1 of 6 people the message was sent to, and I received the message 6 times...so something funky is going on with my loop. $message = $_POST['message']; $emails = $_POST['emails']; foreach ($emails as $e => $value){ $str_emails .= $e . "<br />"; $to = $e; $subject = "You have a message"; $body .= $message . "<br /><br />"; $headers = "From: Nate <nate@email.com>\r\n" . "X-Mailer: php\r\n"; $headers .= "Content-type: text/html\r\n"; if (mail($to, $subject, $body, $headers)) { echo "<p>Message sent to " . $e . "</p>"; }//end if else { echo("<p>Message delivery failed...</p>"); }//end else }//end foreach loop
  12. Is it necessary to have a Foreign Key when performing Joins? From my understanding, a foreign key is the relationship between two tables. But performing Joins creates the relationship as well. Am i on the right rack?
  13. Well alright then. I learned something The script is not complex at all. the only purpose is to have only one admin with the ability to log in. I agree, yes, it's impractical and I would do it in some other way...
  14. yes it looks for the "loggedin" session. If it doesn't exist, it redirects you to login.php
  15. ha yeah that's just a dummy password, of course... impossible? really? eh well.. it is what it is. Like i said, i know zilch
  16. I have this little script that another web designer set up and I am looking over it on a friend of mine's web site. From what little I know about hacking (none, to be honest), I am pretty sure this is an insecure way of logging in. What I would like to know is how insecure and easy it is to crack. login.php: if(isset($_POST['Submit'])){ $username = "admin"; //Set username here $password = "admin"; // Set Password here $username1 = $_POST['username']; $password1= $_POST['password']; if($username==$username1 && $password==$password1){ session_start(); session_register('loggedin'); header( "Location: admin.php" ); }else{ echo "<p align='center'><font color='red'>Wrong Username/Password !!</font></p>"; } } ?>
  17. I have an upload script and I'm wondering how I check to see if the file exists on the server already, and if so, append a 01 or 02 (if there is a 01). Thanks for any advice
  18. Having a little issue with my contact form, where the text field that gets filled out gets all of the extra space stripped out. My code uses htmlentities and strip slashes: $message = htmlentities(stripslashes($_POST['message'])); and a message that has paragraph breaks does not keep the extra space. How can I keep the hard returns? Thanks, -Nate
  19. based on what? based on MySQL errors? input validation errors?
  20. <input type='hidden' name='idz' value='". $_GET['user'] ."'> can you echo that out and tell us what that says? I'm thinking, if you switch up your quotes for the value, that may help. <input type='hidden' name='idz' value="'. $_GET['user'] .'">;
  21. I use this script, although I wish I knew where I got it from so I could give proper credit...I'm thinking w3schools may have had something to do with it Inside my main page, I have a form. <select name="clients" onchange="showProject(this.value)"> <option value="">Select a Client</option> <?php include('includes/mysql_connect.php'); $query = 'SELECT id, clientName FROM client'; while ($row = mysql_fetch_array($result, MYSQL_NUM)){ echo "<option value=\"$row['id']\">$row['clientName']</option>\r"; } ?> </select> This is our script that populates the first "select" field. But then, based on your selection, I needed it to bring up another "select" field, with projects that belong to that specific client. Below </select>, I have a div with the ID of getProject <div id="getProject"></div> In my header, I have my JS: <script language="javascript" src="selectedclient.js"></script> var xmlHttp function showProject(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="getProject.php" url=url+"?q="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("getProject").innerHTML=xmlHttp.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } and then I have one more file, getProject.php <?php $q=$_GET["q"]; $con = mysql_connect('localhost', 'username', 'password'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("dbname", $con); $sql="SELECT projectID, projectName FROM project WHERE clientID = '".$q."'"; $result = mysql_query($sql) or die('Error, query failed'); echo 'Select a Project:'; echo '<select name="optproject">'; echo '<option>Select a Project</option>'; while ($row = mysql_fetch_array($result)){ echo "<option name=\"projects\" value=\"" . $row['projectID'] . "\">" . $row['projectName'] . "</option>"; } echo '</select>'; mysql_close($con); ?> I made a bunch of modifications and changes to this script that I've posted, so you may need to make your own modifications to get it properly working. But you should be able to understand what's going on and learn from it.
  22. I have a simple form I want users to fill out on my page. If Option A is selected, nothing happens and all is well with the value that's there. If Option B is selected, I would like for an additional drop down menu to appear below it with selectable options. How can I achieve this? Thank you for your help!
  23. I am comfortable with MySQL. But to be honest, I really don't know if I should be trying to get comfortable with MySQLi. I don't know if it's better or worse. If MySQLi is better, than it's probably best that you learn on it.
  24. Just off the top of my head...I can't test this so lemme know if this helps: In your form, I added a "value" attribute to the input field: <input name="lastname" type="text" id="get_lastname" value="lastname"> in variables.php, change it to: $get_lastname = trim(stripslashes($_POST['lastname'])); I was going to write out a loop that would retrieve the data from the database, but I just realized you're using mysqli, which I am not familiar with...so I'll stop here and let someone else answer...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.