Jump to content

Don Jajo

Members
  • Posts

    58
  • Joined

  • Last visited

Everything posted by Don Jajo

  1. header("Content-Disposition: attachment; filename="".$download_file.""");
  2. Using PHP >= 4 use this - http://php.net/manual/en/function.crypt.php
  3. ...also, use pathinfo () function to get file extension, i might have a period in my file name before the extension and that gets you an error http://www.w3schools.com/php/func_filesystem_pathinfo.asp
  4. I suggest you paste the content of file_get_html() function
  5. You actually want mail to get sent when every validation requirements are made, learn how to use the "elseif" statement then the mail () function then stays at the last "else" statement which means all requirements are met - http://php.net/manual/en/control-structures.elseif.php
  6. try <?php$con = mysqli_connect(db_details) or die(mysqli_error($con));?>
  7. well, in this instance i use something like uniqid() function which is generated based on microtime - http://www.w3schools.com/php/func_misc_uniqid.asp Then do something like md5(uniqid()) or sha1 I don't think its gonna clash since time changes every second
  8. Because you initiated MySQL connection with MySQLi procedural method and you tried executing the query with OOP method that is why it keeps dying Let your $con be <?php $con = new MySQLi('db_host','db_dbuser','db_pwd','db_name');?> or let your query execution be procedural <?phpmysqli_query($con,$SQL) or die('error');?>
  9. Or set this in the directory .htaccess file DirectoryIndex anotherlink.php
  10. Don Jajo

    \r\n not working

    Coding an email body I don't use n or nr. I just hit the enter key it will also reflect in the mail
  11. Am doubting you read that article $_SERVER['SCRIPT_NAME']
  12. Thanks to justsomeguy, I just learnt new thing now Now the PHP_SELF fetch URL from the address bar, if am using something like <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"><input type="text" name="" /></form> and in the address bar I add this (assuming my file is test.php) test.php/" <script>alert('hello');</script> Check the ouput now
  13. ye, trim() is the best function to handle spaces in the beginning of a string
  14. The above code can work quite well since the content is of each line
  15. Ye, during the explode it also explode empty lines to array thereby making $content to be null. Now am making it show all lines which the content is not null
  16. Quite well seems you don't need the <li> elements because you are replacing it in the output. And for the blank lines, for effective results i suggest you also add it to the foreach loop. Like: foreach($text_contents as $content) { if($content !== null) { $check_url = parse_url($content); //if its a URL add the <a ... if(isset($check_url['host'])) { $content = '<br/><a href="'.$content.'">'.$content.'</a>'; } //Add <li> to all content and pack them back to array $output[] = '<li>'.$content.'</li>';}}
  17. This should work out <?php$text = $text = file_get_contents('list.txt'); // get contents of file//Explode new lines to array$text_contents = explode("n", $text);//Run a foreach to manipulate an array valueforeach($text_contents as $content) { $check_url = parse_url($content); //if its a URL add the <a ... if(isset($check_url['host'])) { $content = '<a href="'.$content.'">'.$content.'</a>'; } //Add <li> to all content and pack them back to array $output[] = '<li>'.$content.'</li>';}//Expload array back to stringsecho implode('', $output);?>
  18. in my projects I do them like these: <?phpdefine('ABSPATH',dirname(__DIR__));?> or <?phpdefine('ABSPATH','/home/user/public_html/');?> When including i now use <?phpinclude(ABSPATH.'file.php');?>
  19. Well, am an iOS user and no current issues on the latest version
  20. Take a look - http://www.w3schools.com/php/php_mysql_insert.asp
  21. then try this way <?phpif(session_destroy()) {echo '<script>alert("Session destroyed")</script>';}?>
  22. Read more about working with MySQL Database and PHP - http://www.w3schools.com/php/php_mysql_intro.asp
  23. I've wrote this once, try this $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['body']; $filename = $_FILES['file']['name']; $size = $_FILES['file']['size']; $mime = $_FILES['file']['type']; $tmp = $_FILES['file']['tmp_name']; $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";$file = fopen($tmp,'rb'); // Now read the file content into a variable $data = fread($file,filesize($tmp)); // close the file fclose($file); // Now we need to encode it and split it into acceptable length lines $data = chunk_split(base64_encode($data)); // Now we'll build the message headers $headers = "From: $emailrn" . "MIME-Version: 1.0rn" . "Content-Type: multipart/mixed;rn" . " boundary="{$mime_boundary}""; // Next, we'll build the message body note that we insert two dashes in front of the MIME boundary when we use it $message = "This is a multi-part message in MIME format.nn" . "--{$mime_boundary}n" . "Content-Type: text/plain; charset="iso-8859-1"n" . "Content-Transfer-Encoding: 7bitnn" . $message . "nn"; // Now we'll insert a boundary to indicate we're starting the attachment we have to specify the content type, file name, and disposition as an attachment, then add the file content and set another boundary to indicate that the end of the file has been reached $message .= "--{$mime_boundary}n" . "Content-Type: {$mime};n" . " name="{$filename}"n" . //"Content-Disposition: attachment;n" . //" filename="{$fileatt_name}"n" . "Content-Transfer-Encoding: base64nn" . $data . "nn" . "--{$mime_boundary}--n"; mail('yourmail@mail.com',$subject,$message,$headers); echo 'Mail Sent!';
  24. Hi, Sessions can't work if the clientside doesn't want it to work by disabling their cookies So since it works normally and later on messes up which may be because the clientside has no cookie enabled browser
×
×
  • Create New...