Jump to content

gotmedia

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gotmedia's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I got $string from another website lol, trying to piece things together. I'm trying to say: "If you type in a password that includes these words 'Google' for example, then you will be redirected to this page -> http://www.google.com" The above will work if you type in "Google, Inc.", "Google Corp", etc. as long as the word "google" (case insensitive) is inputted.
  2. Hi! I'm attempting to do this and feel that I'm fairly close. Would you take a look and throw me any bones? PHP Code: <?php if (isset($_POST['ppassword']) && (stristr($string,'') === TRUE)) { switch($_POST['ppassword']) { case "Google": header("Location: http://www.google.com"); exit(); case "Yahoo": header("Location: http://www.yahoo.com"); exit(); case "Bing": header("Location: http://www.bing.com"); exit(); } } ?> The Form: <form name="portal" id="portal" method="post" action=""> <input name="ppassword" type="text" id="ppassword" maxlength="25" onfocus="this.select()" onblur="this.value=!this.value?'company name':this.value;" value="company name" onclick="this.value=''" /> <input name="login" type="submit" id="login" value="Continue" /> </form> I appreciate any of your help. I feel close and this part (stristr($string,'') feels like the missing piece of the puzzle.
  3. Or would it have to do with this: if($_SERVER['REQUEST_METHOD'] == 'POST'){ ?
  4. OH, I see. Thank you for letting me know! That works when I hit enter on my keyboard. How to make it so that it works if I click "go" or "submit"? I'm researching that, but not turning up results. I tried adding this (isset($_POST['submit'])) but wherever I seem to put it, it doesn't work. Thoughts? <?php // Portal Password if (isset($_POST['password'])) { switch($_POST['password']) { case "pass1": header("Location: http://www.google.com/"); exit(); case "pass2": header("Location: http://www.yahoo.com/"); exit(); default: header("Location: http://www.404.com/"); exit(); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Form</title> </head> <body> <form name="commportalForm" id="commportalForm" method="post" action=""> <input name="password" type="text" id="password" maxlength="5" /> <input name="login" type="button" id="login" value="Go" /> </form> </body> </html>
  5. mjdamato, Okay, sure. I just put that in, but still not working. What did you mean by "PHP processing page in the action parameter"? See below for the code in my form.php file. Here is the link I'm referring to: http://notimeformorning.com/php/form.php <?php // Portal Password if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) { function commPortal() { $val = $_POST['password']; switch($val) { case "pass1": header("Location: http://www.google.com/"); exit(); case "pass2": header("Location: http://www.yahoo.com/"); exit(); default: header("Location: http://www.404.com/"); } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Form</title> </head> <body> <form name="commportalForm" id="commportalForm" method="post" action=""> <input name="password" type="text" id="password" maxlength="5" /> <input name="login" type="button" id="login" value="Go" /> </form> </body> </html>
  6. Sure, I just removed that line which gets rid of the errors and display a form. Thank you kindly! Now, when I click the submit button, it doesn't go anywhere. There must be something I'm missing. I have this in the PHP: switch($_POST['password']) { and this in the form: <input name="password" type="text" id="password" maxlength="9" /> . Is that what's linking those 2 together or is there something else I need? I thought it might have to do with the "action", but I'm not turning up any results. - Steph
  7. Wow that was fast! I learned about 'header', but it sounded like its only use was for PHP includes. Guess not! I put that in and received this error: "unexpected '='". I'll look into it and research it, but if you can throw me a bone, that would be awesome. Updated code: <?php function loginArea() { val = document.loginForm.password.value; switch($_POST['password']) { case "password1": header("Location: http://www.google.com/password1-page/"); exit(); case "password2": header("Location: http://www.google.com/password2-page/"); exit(); default: header("Location: http://www.google.com/sorry/"); exit(); } } ?> <form name="loginForm" id="loginForm" method="post" action=""> <input name="password" type="text" id="password" maxlength="5" /> <input name="login" type="button" id="login" value="Check" onclick="loginArea()" /> </form>
  8. Hi there, I found a Javascript with what I want, but I want it to be in PHP because if people don't have Javascript enabled, they won't see the login. Here is what I have, but I need it to be converted to PHP: function loginArea() { val = document.loginForm.password.value; switch(val) { case "password1": document.location = 'http://www.google.com/password1-page/'; break; case "password2": document.location = 'http://www.google.com/password2-page/'; break; default: document.location ='http://www.google.com/sorry/'; break; } } <form name="loginForm" id="loginForm" method="post" action=""> <input name="password" type="text" id="password" maxlength="5" /> <input name="login" type="button" id="login" value="Check" onclick="loginArea()" /> </form> Help? - Steph
  9. Oh okay, then this right? <?php if ($_SERVER['media']) { echo '<div class="menu"> <ul> <li> <a href="/media/">media</a> </li> <li> <a href="/media2/">media 2</a> </li> <li> <a href="/media3/">media 3</a> </li> </ul> </div>' } else if ($_SERVER['about']) { echo '<div class="menu"> <ul> <li> <a href="/about/">about</a> </li> <li> <a href="/about2/">about 2</a> </li> <li> <a href="/about3/">about 3</a> </li> </ul> </div>' } else if ($_SERVER['extras']) { echo '<div class="menu"> <ul> <li> <a href="/extras/">extras</a> </li> <li> <a href="/extras/">extras</a> </li> <li> <a href="/extras/">extras</a> </li> </ul> </div>' } ?> As read in the link you gave me, it would be ($_SERVER['/public_html/extras/']) since they want the absolute pathname, correct?
  10. Okay cool! Would this work: <?php if ($dir == "media") { echo '<div class="menu"> <ul> <li> <a href="/media/">media</a> </li> <li> <a href="/media2/">media 2</a> </li> <li> <a href="/media3/">media 3</a> </li> </ul> </div>' } else if ($dir == "about") { echo '<div class="menu"> <ul> <li> <a href="/about/">about</a> </li> <li> <a href="/about2/">about 2</a> </li> <li> <a href="/about3/">about 3</a> </li> </ul> </div>' } else if ($dir == "extras") { echo '<div class="menu"> <ul> <li> <a href="/extras/">extras</a> </li> <li> <a href="/extras/">extras</a> </li> <li> <a href="/extras/">extras</a> </li> </ul> </div>' } ?> I think it's pretty close?
  11. I know it's possible, I'm just not sure how. I have a sidebar, and in certain sections, the sidebar menu changes. I want to say "when you are in THIS section, show THIS menu" (in the sidebar). How would I go about doing that?
×
×
  • 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.