Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. The action attribute determines where the form is submitted to. Setting the form action to PHP_SELF will submit the form to itself. if you want the form to goto insert.php then you must set the form action to that. Nothing to do with security. That code you are referring to only repopulates the form values.
  2. Why is PHP handling the countdown? PHP should be used to set the initial time to countdown from. The rest should then be handled by javascript.
  3. The code you are using is not complete code, it is only part 1 of a video series (you can only watch the other videos by signing up to their premium service). But to answer your question, in membership.php you need to save the users username to the session when the verify_Username_and_Pass method returns true. $ensure_credentials = $mysql->verify_Username_and_Pass($un, md5($pwd)); if($ensure_credentials) { $_SESSION['status'] = 'authorized'; $_SESSION['username'] = $un; /* save the users username to session */ header("location: index.php"); Now in index.php you should be able to use echo $_SESSION['username']; to display the logged in users username
  4. Usually using ajax. <script src="myscript.php?uid=123"></script> PHP will receive the uid querystring parameter. But whatever your PHP script outputs the browser will try to parse it as javascript, as this what the browser expects from a <script> tag.
  5. mysqli_query returns a result set. To get out of the result set you need to use one of the mysqli_fetch_* functions $result = mysqli_query("SELECT DOWNLOADS FROM download_manager WHERE id = 'xx'"); // query returns a resultset $data = mysqli_fetch_assoc($result); // get the data from the resultset $body = '<b><font name="Teen" color="#009999" size="11">' . $data['DOWNLOADS'] . '</font></b> ';
  6. After sending the email, dont redirect. Just display the second form directly after <?php if(signup form has been submitted) { // send email } ?> // display second form
  7. Remove the [] in the name. You only need to have that in the name if you are naming other fields the with same name.
  8. You need to replace the while loop while (($file = readdir($directory_handle)) !== false) { ... } with something like $pattern = $directory . DIRECTORY_SEPARATOR . $query . '*'; echo 'Your search pattern ('.$pattern.') matches: '; foreach(glob($pattern) as $file) { // code to list/display files }
  9. Read the manual? http://php.net/glob $filesFound = glob('yo*'); // find any files beginning with yo printf('<pre>%s</pre>', print_r($filesFound, true));
  10. Use the * character in the pattern to match anything, eg to find any files beginning with yo you'd use yo* as the pattern
  11. Is there a question? or problem?
  12. yes, Apache is the webserver. Any changes you have made to the servers configuration (either Apache's httpd.conf or PHP's php.ini) the webserver needs to restarted in order for the changes to take affect. LAMP and WAMP are common acronyms used to describe the software stack a server is using for hosting a website. The first letter represents the operating system/environment, So L is is for Linux, W is for Windows and M is for Mac. The other three letters - AMP - represents Apache, PHP and MySQL.
  13. Then do as mac_gver suggested to do first or add the following as the first couple of lines in your code <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?> Report the errors here There is hardly any difference between the two. The only difference is you need to add i infront of mysql in the function name, and where the connection resource was optional in the mysql_* function it is now required, and is now the first argument to the function that requires it. The bit you maybe confused by is the OOP aspect. Which is fine just concentrate on the procedural functions. The mysqli documentation always gives code examples in both coding styles. Also I didn't notice this earlier, (as I though you where using mysqli). This $conn = mysql_connect($dbhost, $dbuser, $dbpass, $dbbase); Should actually be $conn = mysql_connect($dbhost, $dbuser, $dbpass) mysql_select_db($dbbase); mysql_connect does not have a forth argument for passing the the database name.
  14. If all you're doing is dropping the extension then try just enabling Multiviews Options +Multiviews
  15. So how is the company image added to the cmp_image field in your database?
  16. How is the $setuser array defined?
  17. The metadata is an array. To get the information out of the array you need to loop through it. Example code to display files in a table echo '<p>There are ' . count($metadata['contents']) . ' files in ' . $metadata['path'] . ':</p> <table border=1 cellpadding=10> <tr> <th>Name</th> <th>Siize</th> </tr>'; foreach($metadata['contents'] as $file) { echo '<tr> <td>' . $file['path'] . '</td> <td>' . $file['size'] . '</td> </tr>'; } echo '</table>';
  18. Please dont just dump code here and expect someone to fix it. You should at least explain what it is you're trying to do. Explain what the code should be doing, and post any error(s) your code is producing.
  19. $form_name = $_POST['username']; $form_name = strip_tags($form_name, "'"); $form_name = strip_tags($form_name, '"'); $form_name = strip_tags($form_name, ";"); $form_pass = $_POST['password']; $form_pass = strip_tags($form_pass, "'"); $form_pass = strip_tags($form_pass, '"'); $form_pass = strip_tags($form_pass, ";"); This is code is very insecure, you should use mysql_real_escape_string instead (or better yet convert your code over to use PDO or mysqli and use prepared statements) to protect against sql injection. if(session_is_registered(acp)) session_is_registered is a deprecated function and should not be used. Instead use if(isset($_SESSION['acp']))
  20. Your code is only connecting to mysql when your form has been submitted if(isset($_POST['add'])) { $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $dbbase = 'database'; $conn = mysql_connect($dbhost, $dbuser, $dbpass, $dbbase); if(! $conn ) { die('Could not connect: ' . mysql_error()); } ... Move your database connection code outside of the if $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $dbbase = 'database'; $conn = mysql_connect($dbhost, $dbuser, $dbpass, $dbbase); if(! $conn ) { die('Could not connect: ' . mysql_error()); } if(isset($_POST['add'])) { ...
  21. Try change @name= to name=
  22. When dealing with Javascript make sure you have your browsers console open (try pressing F12 and then clicking the console tab) and making sure no javascript errors are being reported when you click the link for calling the checker javascript function.
  23. yes, Wamp can use a different port. To do so, click the WAMP taskbar icon > Apache > httpd.conf Find Listen 80 and change to Listen 8080 save httpd.conf. Now run WAMP, starting all services, now use http://localhost:8080/ to access localhost
  24. You need to add the users directory size and the file size for the uploaded file together, if the total is less than 5242880 (5GB) then upload the file, else display error. Example $directory_size = new Directory_Calculator; $usersDirectoryFileSize = $directory_size->size($usersDirectoryPath); // calculate users storage space // NB: make sure $usersDirectoryFileSize['size'] returns the directory size in total bytes, not in english readable format like 1.2GB if(($usersDirectoryFileSize['size'] + $_FILES['file']['size']) < 5242880) { move_uploaded_file($_FILES['file']['tmp_name'], 'upload/destination/'.$_FILES['file']['name']); // add the file to the users storage directory } else { echo 'You have exceeded the 5GB storage space. Please delete some files'; }
  25. You need to add the directory separators (the / ) in your file paths. $file = "uploads/{$loggedInUser->username}/$folderon/$file_pr"; $movefile = copy($file, "uploads/{$loggedInUser->username}/$folderon/$folder_in/" . $file_pr); //This script can move a file Also note copy does not move a file, but makes a copy of the original file. If you want to physically move the file you'll want to use rename(). Before moving the file you will also want to make sure the the place where the file is being moved to exists. using file_exists(). If it doesn't exists you will want use mkdir() to create the destination folder(s) beforehand. if you're using a *nix based server you'll want to make the uploads/ folder writeable so php can create files and folders
×
×
  • 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.