Jump to content

piggeh

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Everything posted by piggeh

  1. Thanks for the help. Managed to sort it out and now displays properly by shifting formatting into the other element.
  2. I can't see any top margin on any of my elements. I've only got (so far) the top banner div and then the nav bar.The small amount of black above the nav menu is the border from the banner. I should have probably chosen a different colour to show where the bg color is but it doesnt overlap at the top. Seems it doesn't affect IE though, only FF (havent tested on others yet), The increase/decrease in size in ie keeps the menu constrained to the height of the containing div (ie 25px) but FF increases the size of both and slightly disproportionately, it can start off slightly smaller then as size increases it grows larger than the menu. @JustlikeIcarus - thanks for the reply, posted as I wrote this. Will take a look and see if it helps me solve it.
  3. I currently have a dropdown navigation bar thats text on a blue background. This only goes around halfway across and so I wanted to fill the remaining navigation bar space (on the right of the text) with the same colour background. ie (have done a different colour here to show area affected) as per the attachment. It works at the default heights. However when I resize the text (ctrl + scrollwheel) it becomes slightly too small or large. On the attachment I've highlighted this with the red arrow. Is there a way to get this to conform to the same height as the nav bar text size? Only solution I can currently think of is to size the background colour a pixel or two more than the menu text, as it then wouldnt show, but would rather not do it that way. #navbar { margin: 0; padding: 0; height: 1em; background-color: black; } #navbar li { list-style: none; float: left; } #navbar li a { display: block; padding: 3px 8px; background-color: #5e8ce9; color: #fff; text-decoration: none; } #navbar li ul { display: none; width: 10em; /* Width to help Opera out */ background-color: #69f;} #navbar li:hover ul, #navbar li.hover ul { display: block; position: absolute; margin: 0; padding: 0; } #navbar li:hover li, #navbar li.hover li { float: none; } #navbar li:hover li a, #navbar li.hover li a { background-color: #69f; border-bottom: 1px solid #fff; color: #000; } #navbar li li a:hover { background-color: yellow; } #nav_container ul { width: 782px; height: 25px; } <script type="text/javascript"> sfHover = function() { var sfEls = document.getElementById("navbar").getElementsByTagName("li"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=" hover"; } sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" hover\\b"), ""); } } } if (window.attachEvent) window.attachEvent("onload", sfHover); </script> <div id="nav_container"> <ul id="navbar"> <li><a href="./index.php">Home</a> </li> <li><a href="./index.php?load=news.php">News</a><ul> <li><a href="./index.php?load=news_main.php">Subitem One</a></li></ul> </li> <li><a href="./index.php?load=matches.php">Matches</a><ul> <li><a href="./index.php?load=previews.php">Previews</a></li> <li><a href="./index.php?load=reports.php">Reports</a></li></ul> </li> </ul> </div> Thanks for any help. [attachment deleted by admin]
  4. Thanks. I updated my code and it works fine now, many thanks for the guidance. Seems I spent too long between studiyng and doing sometihng practical and have forgotten some of the basics!
  5. code is now: <?php class fieldcheck { private $inputerror = "test"; function __construct() { //this needs to do checks that apply to all form field types - ie malicious data check } //checks for blank inputs function valBlanks($n) { if (empty($n)) { $this->setError("required field is blank <br />"); return false; } else { return true; } } function valEmail($n) { if (!filter_var($n, FILTER_VALIDATE_EMAIL)) { $this->setError("email address is not valid <br />"); return false; } else { return true; } } function valMatch($n, $p) { if ($n !== $p) { $this->setError("passwords do not match<br />"); return false; } else { return true; } } function checkEmail($n) { if($this->valEmail($n) && $this->valBlanks($n)) { return true; } else { return false; } } function checkPasswords($n, $p) { $this->valMatch($n, $p); } function setError($n) { $this->inputerror = $n; } function getError() { return $this->inputerror; } } ?> I guess if I passed enough info to it on instantiation I could skip the $check->checkEmail() etc lines on the registration form but will save that for another day, just want to get this working properly first. I looked up my notes and the set/get error part is almost lifted the same as from the book (learning from SAM's teach yourself php in 24 hours initially).
  6. Thanks - I have updated (and taken out testdata variable as wasnt being used) - the construct class is a bit redundant as well really at the moment - but it still does the same as before (no error messages)
  7. OK - I have made a couple of changes.. registrationoop.php <?php $user = $_POST["username"]; $pwd = $_POST["password"]; $pwd2 = $_POST["password1"]; $email = $_POST["email"]; $inputcheck = $_POST["inputcheck"]; $error; include_once("formcheck.php"); //check for previous input. if exists, check input using formcheck.php methods if ($inputcheck==1) { echo "checking inputs.."; $checker = new fieldcheck(); //check for erros from above, if all reutrned true then process form if ($checker->checkEmail($email)) { echo "processing form"; //process form } else { echo $checker->getError; echo "error encountered.."; //show form again if error variable contains values ie error messages //consider moving form and using include_once() to allow seperation of elements ?> <form action="registrationoop.php" method="post" > username:<input type="text" name="username" value="<?php echo($_POST["username"]); ?>" /><br /> password:<input type="password" name="password" /><br /> re-enter password:<input type="password" name="password1" /><br /> email:<input type="text" name="email" value="<?php echo($_POST["email"]); ?>" /><br /> <input type="hidden" name="inputcheck" value="1" /><br /> <p><input type="submit" value="submit" /> <?php } //check for input with hidden input variable } else { //else, no input or previous visit, display form ?> <form action="registrationoop.php" method="post" > username:<input type="text" name="username" /><br /> password:<input type="password" name="password" /><br /> re-enter password:<input type="password" name="password1" /><br /> email:<input type="text" name="email" /><br /> <input type="hidden" name="inputcheck" value="1" /><br /> <p><input type="submit" value="submit" /> <?php } ?> formcheck.php <?php class fieldcheck { var $testdata; var $inputerror = "test"; function _constructor($n) { //this needs to do checks that apply to all form field types - ie malicious data check } //checks for blank inputs function valBlanks($n) { if (empty($n)) { $this->setError("required field is blank <br />"); return false; } else { return true; } } function valEmail($n) { if (!filter_var($n, FILTER_VALIDATE_EMAIL)) { $this->setError("email address is not valid <br />"); return false; } else { return true; } } function valMatch($n, $p) { if ($n !== $p) { $this->setError("passwords do not match<br />"); return false; } else { return true; } } function checkEmail($n) { if($this->valEmail($n) && $this->valBlanks($n)) { return true; } else { return false; } } function checkPasswords($n, $p) { $this->valMatch($n, $p); } function setError($n) { $this->inputerror = $n; } function getError() { return $this->inputerror; } } ?> I have firstly changed it so rather than checking for error variables it checks if functions evaluate to true or false. At the moment it just checks email address and no others as I thought it's best to get one field working before implementing the rest. It seems to evaluate correctly - if I fill in an email address it will print 'processing form'. However when I leave it blank it prints 'an error has occurred' but does not output the errors. Now, I know setErrors will mean only one error is stored but it's not printing that error and not even printing 'test' (which I put as a default value for the variable to check if it outputs). Where am I going wrong?
  8. I do things differently - rather than having an 'active' field I have two tables, ver_users and users. I send them a verification link and once they load the page up, it moves their user details from ver_users to the users table. Then I dont need to check an active flag when they log in and the users table only contains verified users.
  9. I load it up today and error doesn't occur. I think xampp was not refreshing the script or sometihng strange was happening. I'm not too sure how an error handling function would work but I will try and look up an example. I guess it's easy enough if I just want the error to be printed but ideally want to display errors and reload the form at the same time.
  10. My stuff is on my memory stick at the mo, will get it up and running at work tomorrow and copy the error message
  11. Damn, forgot to do the verification and lost my post.. line 13 is if (empty($n)) { Would the variable (property?) $error1 not be accessible to the main script? Do I need to call an error handling function instead? If so how would this then return something to the main script? Currently he main script acts like: If hiddenvariablesubmittedwithform is empty, display form; If not then if error variable contains enything, display error and form again; if not, then process form.
  12. Hi all I am fairly new to PHP programming. I recently devised a registration script that checks the input of a form, checks against a database etc, then sends a verification link to an email address, before verifying the user. All worked fine. However I'm interesting in learning how to do this in an object based way rather than coding every single script. I got thus far (obviously this is fairly basic atm): $user = $_POST["username"]; $pwd = $_POST["password"]; $pwd2 = $_POST["password1"]; $email = $_POST["email"]; $inputcheck = $_POST["inputcheck"]; $error; include_once("formcheck.php"); $checker = new fieldcheck(); $checker->checkEmail($email); The formcheck.php is as follows: <?php class fieldcheck { var $error1; function _constructor($n) { //this needs to do checks that apply to all form field types - ie malicious data check } //checks for blank inputs function valBlanks($n) { if (empty($n)) { $this->error1 .= "$n is blank <br />"; return $error1; } return; } function valEmail($n) { if (!filter_var($n, FILTER_VALIDATE_EMAIL)) { $this->error1 .= "email address is not valid <br />"; return $error1 ; } return; } function valMatch($n, $p) { if ($n !== $p) { $error1 .="passwords do not match <br />"; return £error1; } return; } function checkEmail($n) { $this->valEmail($n); $this->valBlanks($n); } function checkPasswords($n, $p) { $this->valMatch($n, $p); } } ?> I get an error on the above (something about 'expected syntax '`)" on line 13 of the formcheck.php script) but I could not see any obvious error. Also is my syntax correct, especially on the this->valMatch etc. Do I need to pass variables to objects in a certain way? Any help appreciated, thank you.
×
×
  • 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.