Jump to content

Strider64

Members
  • Posts

    473
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by Strider64

  1. You escape double quotes this way echo "<td><input type=\"text\" name=\"textfield\" value=\"" . $providerid . "\" ></td>";
  2. I don't know why but I found myself messing around with this code I know this isn't the way it's supposed to be done, but this is definitely screaming database... I wasn't going to post this, but I thought well it might help you out a little. activities.php <?php $msg = ""; $activites = array ('Paintballing', 'Ice_skating', 'Horse_riding', 'para_gliding', 'water_rafting'); $output = "<nav><ul>" ; foreach ($activites as $key => $value) { $output .= "<li><a href=\"activities.php?page=" . ($key+1) . "\" >" . $value . "</a></li>"; $message[$key+1] = "We trust you will enjoy " . $value . " today. Have fun and create memories"; } $output .= "</ul></nav>"; if (isset($_GET['page'])) { switch ($_GET['page']) { case 1: $msg = $message[1]; break; case 2: $msg = $message[2]; break; case 3: $msg = $message[3]; break; case 4: $msg = $message[4]; break; case 5: $msg = $message[5]; break; } } ?> <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <style type="text/css"> nav { clear: both; display: block; width: 200px; height: 120px; padding: 0px; margin: 0px; } nav ul { list-style: none; padding: 0px; margin: 0px; } nav ul li { padding: 0px; margin: 0px; } nav ul li a { float: left; display: block; width: 180px; height: 25px; background: #ebebeb; border-bottom: 1px solid #40352F; font-family: Arial, Helvetica, sans-serif; font-size: 1.0em; line-height: 25px; color: #1C11B5; font-weight: bold; text-decoration: none; padding: 0px 10px 0px 10px; margin: 0px; } nav ul li a:hover { color: #40352F; background: #FEE494; padding: 0px 10px 0px 10px; margin: 0px; } </style> <title>Untitled Document</title> </head> <body> <H1>Please select an activity from the drop down menu</H1> <?php echo $output; ?> <p><?php echo $msg; ?></p> </body> </html>
  3. You could do something like this? <form action="user.page.php?page=3" method="post"> <input type="hidden" name="action" value="process" /> <input type="text" name="phone" value="" /> <input type="submit" name="submitButton" id="submitButton" value="SUBMIT" /></form><br /> Then all you have to do is something like this if ( isset( $_POST["action"] ) and $_POST["action"] == "process" ) { $phone = htmlspecialchars($_POST['phone']); // Your function to the write to database? } The above would probably be best at the top of you page before the header portion of your html.
  4. I don't know if this will help or confuse you even more, but this is what I do, it works for me. private $db_host = "localhost"; private $db_username = "root"; private $db_password = "******"; private $db_name = "your_database"; public function __construct() { $this->database = new mysqli($this->db_host, $this->db_username, $this->db_password, $this->db_name) or die($this->database->error); // Note to self the die function is not going to be used for production website... } Then I just use $this->database to connect to the database Even though it's a public constructor, I find that I can still encapsulate my other variables and method /functions using protected variables and methods/functions throughout my code.
  5. <?php class Test { public $greetings; // Public Variable can be used anywhere public function my_world($x) // Global Method { echo "Good Afternoon, " . $x . "!<br />"; return $this->greetings = "Have a Great Day " . $x . "!<br />"; // returns a varialble to the calling method } } $thetest = new Test; // Creat a new instance $goodbye = $thetest->my_world("Kevin"); // Call the Method echo $goodbye; //display it. ?>
  6. Instead of getting speific why don't you just see if a user is login with sessions? For example // First we execute our common code to connection to the database and start the session require("includes/common.php"); // At the top of the page we check to see whether the user is logged in or not if(empty($_SESSION['user'])) { // If they are not, we redirect them to the login page. header("Location: login.php"); // Remember that this die statement is absolutely critical. Without it, // people can view your members-only content without logging in. die("Redirecting to login.php"); }
  7. I created a simple bad word function using stripos function bad_word_filter($text, $bypass_write=false) { $patterns = array(); //bad words list $patterns[0] = '****'; //Obviously bad words would go here $patterns[1] = '****'; $patterns[2] = '****'; $patterns[3] = '****t'; foreach ($patterns as $check_for_word) { if (stripos($text, $check_for_word) !== false) { $bypass_write = true; // logica value to bypass write to dateabase check. break; } } return $bypass_write; } It's a basic function and simplistic bad words function (though I guess a person could make it more complex if he/she chooses), but it serves it's purpuse for me in my small cms webpage. Pretty neat little function this stripos is.
  8. I am a graphics designer from Liviona, MI. I have been dabbling with PHP for years, but the last couple of months I have buckled down to learn php. Right now I am developing my own CMS using PHP. I have finally gotten how to wirte secure (well is secure php is a relative word isn't it. ) using mysqli and prepared queries, eventually I want to get into using PDO. Anyways, getting off topic, for this is the Introduction section. I have been dabbling with computers since the early 1980s and have been building my own computers since 2000. I used to run a BBS (Bulletin Board Service) that preceded the explosiion of the internet and remember connections of 300 bps and remember downloading files that would take 6 hours or more that were roughly 75K in size. So yes I'm a dinosaur when it comes to computing, but I plan on keeping up on tech and learing new languages until my last breath. Have a nice day everyone, John
×
×
  • 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.