Jump to content

MFHJoe

Members
  • Posts

    91
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

MFHJoe's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Errrrm, yeah. Smarty is only for templating. Frameworks like CakePHP do have a templating system, but they also do lots of other stuff as well.
  2. Yep, that's it. It's replacing < with < and > with > which is messing with your HTML. You could change BBCode to: <?php //bb code fucntion function BBCode($BB){ $BBCode = array("&" => "&", "[b]" => "<b>", "[/b]" => "</b>", "[i]" => "<i>", "[/i]" => "</i>", "[u]" => "<u>", "[/u]" => "</u>", $Message = str_replace(array_keys($BBCode), array_values($BBCode), $BB); return $Message; } ?> And that should fix things up.
  3. I think you need quotes on your field names: $sql="INSERT INTO clients ('client_fname', 'client_lname', 'client_address', 'client_city', 'client_state', 'client_zipcode', 'client_phone', 'client_cphone', 'client_email', 'client_website', 'client_notes') VALUES('$client_fname','$client_lname','$client_address','$client_city','$client_state','$client_zipcode','$client_phone','$client_cphone','$client_email','$client_website','$client_notes')";
  4. Could it be something in the BBCode function? I tried: $Message = "Hello there\n\nHello there"; $Output = ucfirst(nl2br(strip_tags($Message))); echo $Output; ?> And it seemed to work fine so it's probably the BBCode function. Try getting rid of mysql_real_escape_string (temporarily) and see if that makes a difference - I'm not hopeful about that one though. I'd put my money on BBCode.
  5. Sorry mate I really don't understand the problem. Could you elaborate?
  6. Use the HTML: <select name="department"> <option value="Sales">Sales</option> <option value="Marketing">Marketing</option> <option value="Support">Support</option> </select> Then add to your PHP something like: <?php $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $department = $_REQUEST['department']; if($department == 'Sales') { $sendto = 'sales@yoursite.com'; } elseif($department == 'Marketing') { $sendto = 'marketing@yoursite.com'; } elseif($department == 'Support') { $sendto = 'support@yoursite.com'; } mail( $sendto, "REQUEST", $message, "From: $email" ); header( "Location: http://www.mysite.com/thankyou.html" ); ?>
  7. <?php $str = "house, cup, cup, house, place, smile, cup, house, place"; $arr = explode(', ', $str); $arr = array_unique($arr); $val = implode(', ', $arr); echo $val; ?>
  8. Add a last posted field to the users table in the database with the PHP time() function (or the SQL equivalent). Then just run an if statement on that field before you insert the post into the posts table.
  9. Yes, that could be very possible actually. Especially if a similar code works for you on another site.
  10. Ruby on Rails is looking pretty good for that kind of thing too. But PHP is much more widely supported at the minute. Version 4 is deprecated. Learn version 5. Just make sure the webhost you're going to use is using version 5 as well (sometimes they don't). Read the book, if it doesn't help much, then just look on the internet. There's a ridiculous amount of PHP tutorials around (PHPFreaks has some good ones). Smarty is a (very good) templating engine. It's used to separate HTML and CSS from PHP which makes things cleaner and is generally better programming practise. MVC is a totally different style of coding. It stands for Model-View-Controller, models being the main code, views being the user interface and controllers being the code that interprets what the user is inputting. There's loads of books/online tutorials about MVC, and it's a really good thing to learn if you have the time (I can see programming in the future relying heavily on MVC). Start with the basics. Forget all about templating engines, frameworks, PEAR, etc. Learn about arrays, different variable types, etc. Then move on to mysql connections. Depending on how much programming you've done in the past it may take a while to get past the first few steps but once you've done that you'll be flying (PHP is like that). php.net is your friend. If you ever need to know how a function works, it'll tell you (in great detail) over there. PHPFreaks has some useful tutorials that you should read. So does W3Schools. Some other people will definitely have some good resources for you as well.
  11. You don't have to type echo each line mate. Just do one. They can span multiple lines: echo "<div class='admin-property-box'>\n <h1>$row[name]</h1><div style='clear:both'>&nbsp</div>\n <form action='$_SERVER[REQUEST_URI]' enctype='multipart/form-data' method='POST'>\n <label for='name'>Property Name:</label> <input type='text' name='name' value=''><br />\n <label for='name'>Price:</label> <input type='text' name='price' value=''><br />\n <label for='date'>Date:</label>\n"; @include "form-date.inc"; echo "<br /> <label for='description'>Description:</label>\n <textarea rows='5' cols='50' name='description'>\n $row[description]\n </textarea><br />\n <br />Location:<br />\n"; Works just as well.
  12. EDIT: Nhoj got there before me It'd be better doing it with the code below. Nhoj's would work well, unless the user happened to have some weird characters in their password - those characters would be taken out by stripslashes() and mysql_real_escape_string() and the user wouldn't be able to login, even though he was using the password he signed up with. I've commented the bits I've changed. The code below should work. <?php $host="xxxx"; $username="xxxx"; $password="xxxx1"; $db_name="xxxx"; $tbl_name="xxxx"; // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myusername=$_POST['UID']; // Encrypt the line below so it may match what's in the database $mypassword=md5($_POST['password']); // To protect MySQL injection $myusername = stripslashes($myusername); $myusername = mysql_real_escape_string($myusername); // $mypassword = stripslashes($mypassword); You don't need to stripslashes, it's already md5() encoded so it's safe // $mypassword = mysql_real_escape_string($mypassword); Again, no need. It's already md5() so it's safe. $sql="SELECT * FROM $tbl_name WHERE UID='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword, set cookie and redirect to file session_register("UID"); session_register("password"); header("location:resources.php"); } else { header("location:loginerror.html"); } ?>
  13. No need to bump the thread after 1 minute. Anyway, just make a form that looks something like: <form enctype="multipart/form-data" action="upload.php" method="post"> Upload File: <input name="file" type="file" /><br /> <input type="submit" name="submitfile" /> </form[code] Note the enctype - it's very important. Once the user submits the form the file gets uploaded to a temporary place on the server. You can access it with $_FILES['file']['tmp_name']. You need to move it to another location on your server (eg. D:\users\uploaded_files) using the move_uploaded_file() function. [/code]
  14. It's no better/worse than any of the other methods really. They're all just used in different situations, but, ultimately, they all do the same thing.
  15. I'd say it's personal preference to be honest. I prefer method 1, and it's probably (marginally) quicker as PHP doesn't have to keep stopping and starting. You could alternatively use the heredoc syntax which was discussed quite a lot here yesterday.
×
×
  • 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.