Jump to content

kierany5

Members
  • Posts

    21
  • Joined

  • Last visited

kierany5's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Just to be sure, you have started the session with: session_start(); Haven't you? I assume this is a snippet of the code... Make sure you put it in a form. <form action="" method="post"> <!-- inputs here --> </form> Also, you sound make sure you properly validate $lang to prevent XSS attacks. Lastly, in your switch statement you have misspelt english... In fact, you have in the select as well...
  2. I highly recommend moving to a pre-built library. I rarely suggest that, but email is a whole different beast. Take a look at PHPMailer (I've used this for years, even though they are alternatives which some argue are better). It does all the messy work for you. Unicode, emails and PHP don't work well together sometimes. The code looks correct, it least as far as I can tell. Is it only unicode characters it isn't working with? Is the file being uploaded correctly (it could be PHPs lack of unicode causing the issue)? As a side note, you are using the ereg_ functions - which are now depreciated. You should move on to preg_ functions as soon as possible, because ereg_ functions will be removed in a future version of PHP.
  3. The error message says it all... $sel_page hasn't been set before you've echoed it. It's only a notice, so it's not the end of the world. If this is on production, make sure you turn display_errors off in your php.ini (or use ini_set('display_errors', 0) if you don't have php.ini access). So, simply put, in the the code you've included this file from, you've declared $sel_subject but you haven't declared $sel_page...
  4. function yourSearch($needle, $haystack) { foreach($haystack as $i => $v) { if(array_search($needle, $v) !== false) return $i; } return false; } Something like the above? So, echo yourSearch('8R195', $item1); should give A
  5. $features .= implode(', ', $_POST['features']); Did you mean if you comment out that line, it works? Try without the dot. Also, for security, make sure you html escape the strings - the inputs may contain malicious JavaScript. Use htmlspecialchars() for this.
  6. PHP can do this. See the doc: http://php.net/manual/en/book.image.php Use imagecreatefromjpeg() then the rest is quite simple from the docs. JPGs don't have transparency, so how can you remove it?
  7. Hi, Your form names are different. Line 228/244 should be: <input class="field" type="text" name="userName" id="userName" value="" size="23" /> Line 231/252 should be: <input class="field" type="text" name="password" id="password" value="" size="23" /> Warning: You are susceptible to an SQL Injection - which is very, very bad You MUST Validate and escape user inputs. E.g. $userName = mysql_real_escape_string($_POST['userName']); Also note that you should move to mysqli or PDO since the mysql functions are now depreciated. Mysqli in procedural form is very similar to the mysql functions.
  8. So that's what it is, an IDE. I had not idea what Android Studio is. When I referred to windows or linux, I meant the machine the PHP is being executed on. For example, I develop on a mac but my code is executed on one of my servers, all running a distribution of Linux. So, if your code is being run on a windows machine you'll need to download some additional libraries to send straight from the script if you don't want to use SMTP. Once again, I seriously recommend PHPMailer or some other library - they cut out the non-sense you have to go through when sending html emails, etc.
  9. I have to say, when I registered it took many attempts the get the captcha correct. After refreshing the page, it worked so I suspect something isn't fully working on the registration page... I didn't try the Facebook or twitter options...
  10. You can use the mail() function, which on linux uses sendmail (or postfix, etc). Windows requires additional tools. You could also use a library like PHPMailer. You can use SMTP using this library.
  11. $myValue = (isset($_GET['myKeyName']) ? $_GET['myKeyName'] : defaultValue); So when $_GET['myKeyName'] is not set, it uses defaultValue. You can't include("../content_header.php?search=true"); ​You can access $_GET variables set on the parent script in the child script.... E.g. I go to /example.php?search=test In example.php: <?php include('include.php'); ?> In include.php <?php echo $_GET['search']; ?> Hope that makes sense. {addition} $_GET is a Superglobal, as documented here: http://php.net/manual/en/language.variables.superglobals.php Same as $_POST, $_SERVER, etc. These are set when PHP starts running the script. The include functions don't start a new PHP process, it brings the include script into your current script and runs it.
  12. Here is a different idea: shared memory. Take a look at the doc: http://php.net/manual/en/book.shmop.php Using semaphores to lock/unlock the shared memory. Then it as readable and writable by all php scripts running. Very quick as well. Much quicker than using a database and with much less overhead. Though, for a simple variable memcached or something could perform the same function. I needed more control than memcached provides in my system for certain tasks...
  13. I find it very difficult to interpret your question. I believe you are asking if you should use a different database for each branch of a shop/business. If so, it depends. If you are using the same system for each branch, then I would say no. Just give each branch an ID in a branches table, then use this in your stock table. But, by the sound of it, you're in a little too deep...
  14. Use <input type="checkbox" name="course[]" value="<?php echo $line["course_id"]; ?>" /><?php echo $line["course_name"]; ?> Then $_POST['course'] is an array(); if (isset($_POST['save'])) { for($x=0, $c=count($_POST['course']); $x<$c; $x++) { $course_id = mysql_real_escape_string($_POST['course'][$x]); // I recommend doing more validation, e.g. checking if it exists in the courses table... mysql_query("insert into organization (course_id) values ('$course_id')") or die(mysql_error()); } } Note the real_escape_string - I am preventing an SQL Injection by escaping the value... Always escape and validate user inputs. Also note the mysql function are depreciated. You should be using mysqli or PDO instead, as mysql WILL be removed in a future version of PHP. Hope this answers your question.
  15. Not quite sure what you are asking exactly. If you want to redirect them, then <?php header('Location: http://www.example2.com'); die(); If you want to get the content from example2.com, then you have a couple of options. Remote file open or cURL (if you have it installed) are the two the spring to mind. Personally, I would use cURL: <?php $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://www.example2.com'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // If 0, curl_exec will print data $content = curl_exec($curl); ?> This can slow down your script quite a bit though...
×
×
  • 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.