Jump to content

pianoman993

Members
  • Posts

    68
  • Joined

  • Last visited

    Never

Everything posted by pianoman993

  1. Quick question, I've been trying to figure out a way to use this preg_match function if (!preg_match('/\A(?!-|_)[-_a-zA-Z0-9]{6,20}|(?<!-|_)\z/', $username)) but add an additional rule allowing only ONE space in the $username string. I fear the solution is aggravatingly simple
  2. Great, i will do that thanks. Oh and one more thing, how do I make it so that a hyphen can not be the last character of the $username string?
  3. As for length I have a if(!substr($username,6,20)) {} condition. Underscores are not permitted. Thanks for your help.
  4. Alphanumeric values and hyphens. There can be no hyphen at the beginning of the string.
  5. How do I validate a $username string by checking if it contains charactors such as ?!-+= etc... ? I'm not sure if your supposed to use eregi or preg_match or what. If someone knows the answer please post your code below. Thanks!
  6. THanks for the code rework however, it still does not solve the problem. I may in the end just recode the pages to some sort of unconventional technique to solve the problem.
  7. I tried your method however I got an error message: Here is what I used as my code: Message: implode() [function.implode]: Invalid arguments passed $pointer = implode(",","$errors"); $data['problems'] = array($pointer); It seemed I was closest when I used print_r
  8. Thanks for the help so far, I hope this code can make things more specific: Here's one page's code: if (empty($_POST['username'])) { $errors = 'Please enter your username'; } else { $username = $_POST['username']; global $username; } if ( (empty($_POST['password'])) || (empty($_POST['conf_password'])) ) { $errors = 'Please enter your password'; } else { $password = $_POST['password']; global $password; } if ( (empty($_POST['email'])) || (empty($_POST['conf_email'])) ) { $errors = 'Please enter your email'; } else { $email = $_POST['email']; global $email; } if ($errors) { $data['problems'] = array('One','Two'); $this->template->load('register/register_view',$data); } else { echo 'Huge Success!'; } The second page's code using information from the first page: <?php if (isset($problems)) { foreach($problems as $message) echo "$message<br />"; } ?> <b>Registration Page</b> <div id="registration"><table> <?=form_open('register/handle')?> <tr><td>Username:</td><td><input type="text" name="username" /></td></tr> <tr><td>Password:</td><td><input type="password" name="password" /></td></tr> <tr><td>Confirm Password:</td><td><input type="password" name="conf_password" /></td></tr> <tr><td>Email:</td><td><input type="text" name="email" /></td></tr> <tr><td>Confirm Email:</td><td><input type="text" name="conf_email" /></td></tr> <tr><td colspan="2"><input type="submit" name="submit" value="Register" /></td></tr> </table></div><!--Registration--> My goal is to somehow get out all of the values from the $errors array and insert them... $data['problems'] = new array( *right here* )
  9. I am having a heck a of a time trying to insert an array into an array. To illustrate this, I am using an array called $errors and trying to insert the values from $errors into an array called $problems like so: array( *errors array values here* ); AHH!! heelp! much thanks - mark
  10. Thanks a bunch for sticking with my nooby questions, I hope I can just bug you a tad longer, hopefully for the final time. I have installed a CodeIgniter Framework and have a rudimentary understanding of how it's new syntax works. Above you said that I should use the template engine Smarty. I downloaded it and tried to incorporate it into my website however, it seems that it has it's own syntax and operates the same way CodeIgniter does in seperating logic and presentation. Additionaly, I find it increasingly frustrating by the lack of websites explaining these special syntaxs employed by these frameworks. It has seemed through the various php blog pages I've visisted that Smarty and CodeIgniter are joyously simple and take little-to-no time to use.... argh! I hope I am just missing some really helpful websites with tutorials and explanations for beginners like me. Thanks for everything, Mark
  11. Alrighty, well I have researched mod_rewrite, the template engine Smarty, and CodeIgniter. I have learned a lot and am ready to make sense out of your response to my earlier post. Question One: In my earlier post I had the desire to create a website in which I would have a logical and commonly used system of displaying and editing information. So I researched template engines. It simply seemed to me that template engines act as code repositories like PEAR and allow for separation of presentation and code. If this is the case, I wondered if this is the fundamental way sites such as Facebook and DeviantArt work. Question Two: Also, I checked out mod_rewriting which was extremely informative describing how sites like Apple.com displayed their information. I brainstormed a couple of ideas on how to quickly and painlessly integrate mod_rewriting with my own php "template" and this is the idea I thought up: You have one main .php file that checks the url against the basename() function for the name of the current script. With the name of the current script (such as index.php) a switch statement detects the filename and inserts the correlating module. Thus in this way you could have one file such as config.php included in every file on your page. In otherwords contact.php would have a config.php included inside of it that would indentify the file presently viewed as contact.php and load the proper module. Is this a sensible solution? Two questions, any help would really very very useful. Thanks, Mark
  12. Thank you Thank you Thank you! That was extremely helpful
  13. I'm struggling to find the correct approach to creating a php website (obviously presented through HTML and CSS). I'm aware the include() and require() functions are essential in the process of creating a template. I have already tried creating a site using a switch statement to recognize webpages by sending variables via the _GET method in the url, however this did not seem logical since every page ended with an unnecessarily long url (ex: www.mydomain.com?p=login). So this all boils down to my originial question, what is the correct way to script a php template that does not force the programmer to write html for each page (ex. home.php, login.php, content.php). :/ - Mark
  14. ahhh very wise indeed. Thanks for the post!
  15. Hey guys, I've got an extremely nooby login script. Among other problems, none of the passwords are encyrpted, which they will be. This is just a simple simple script. Here is the code I wrote, it does not work evidently. Is there any reason why? If so could post the revised code please. Many thanks to everyone. <?php error_reporting(E_ALL | E_STRICT); ini_set('display_errors', True); if (isset($_POST['login_submit'])) { $username = htmlentities($_POST['login_username']); $password = htmlentities($_POST['login_password']); // Connect to database require_once('../excludes/dbc.php'); $connection = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$connection) die('Could not connect to host'); mysql_select_db(DB_NAME, $connection); $result = mysql_query("SELECT username, password FROM users WHERE username = '$username' AND password = '$password' "); if($result) $row = mysql_fetch_array($result, MYSQL_ASSOC); if(($row['username'] = $username) AND ($row['password'] = $password)) { $loggenin = TRUE; echo '<b>You have successfully logged in!</b><br />Welcome '.$username; echo '<br /><a href="?">Back up</a>'; } else { $loggenin = False; echo '<b><span style="color:red">Login failed</span></b>'; echo '<br /><a href="?">Back up</a>'; } } else { echo "<form action='?' method='post' class='login'> Username:<br /><input name='login_username' class='text_input width_100' type='text' /><div class='space'></div> Password:<br /><input name='login_password' class='text_input width_100' type='password' /><br /> <div class='space'></div><input type='checkbox' class='checkbox_input'/>Remember me<br /><div class='space'></div> <input type='submit' name='login_submit' value='Login' class='click_input' /> <div class='space'></div><a class='s_10 forgotpassword' href='#'>Forgot Password?</a> </form>"; } ?>
  16. Hi, I have a pretty nooby question so here it is. I have a site that functions in three parts, (it is comprised of 3 columns). THe first column is for logging in and navigation (if successfully logged in) the second is for content, the third for forum information. I would like to control all my scripts using the main index.php page and to do that I am currently using a switch statement to identify a page variable sent to the URL. for example: mysite.com?index.php?p="signup" This is identified through the switch statements and changes the second column's information accordingly. Here's the problem: How do I make 2 links so that for instance if I had a user click a button that would change information in the first column like column1="nav", would then still have the p="signup" still be in its place? If you weren't able to understand what I just said, (which is understandable) I'll restate it differently. 1. A user enters the site, enters the loggin information and successfully enters the site. 2. They click on the forum link, and the forum column changes. 3. THey then click on the add text button and the 2nd column changes but the 3rd column still stays the same. How do I do this?
×
×
  • 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.