Jump to content

kayz100

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by kayz100

  1. Hi guys, thanks for all your help. I am trying to use php pagination without mysqli on one of my pages and I have the following php script. however, it keeps outputting an error that $page is not indexed please help and also how to put a css style attribute to my arrays. <?php $array = array('Music and chairs','hello mama','c','d','e','f','g','h','i','j'); //failing to put styles on this info array $total_data = count($array); // COUNTING TOTAL ARRAY $per_page = 3; // Outputting error on the $page below $page = intval($_GET['page']); // Error output is this - Undefined index: page if(empty($page) || $page==1) { $start_val = 0; $end_val = $per_page - 1; } else { $start_val = ($page * $per_page) - $per_page; $end_val = $start_val + ($per_page - 1); } //Echoing my array and failing to use my css for($i=$start_val;$i<=$end_val;$i++){ echo $array[$i].' '; } $less_than = $total_data/$per_page; if($less_than>intval($less_than)) $less_than = $less_than + 1; if($total_data>1) { echo '<div class="pagination">'; echo ($page-1)>0?'<a href="?page='.($page-1).'">Previous</a> ':'Previous '; for($i=1;$i<=$less_than;$i++){ if($page==$i) echo '<a class="paginator linkno">'; else echo '<a href="?page='.$i.'" class="paginator">'; echo $i; echo '</a> '; } echo ($page+1)<=$less_than?'<a href="?page='.($page+1).'">Next</a>':'Next'; echo '</div>'; } ?>
  2. Hi guys, Please help, my css image enlarge on mouse hover is not behaving. The main div is failing to center even though I have used margin:0 auto; I want it to enlarge image on hover without adjusting other div elements. I would love it to enlarge image with text, tried using javascript but no success. <html> <head> <style type="text/css"> .myimg { position:relative; width:50%; top:0px; } .myimg:hover { width:80%; z-index:9999; } .Enlrg ul {clear:both; list-style-type:none; } .Enlrg li {width:20%; float: left; overflow:visible; display: block; } </style> </head> <body> <div style="margin:0 auto; background:gray; width:80%;"> <div class="Enlrg"> <ul> <li><img class="myimg" src="pic1.jpg" alt="Rocasa Future classroom" /></li> <li><img class="myimg" src="pic2.jpg" alt="Rocasa Future classroom" /></li> <li><img class="myimg" src="pic3.jpg" alt="Rocasa Future classroom" /></li> </ul> </div> </div> </body></html>
  3. Hi guys How do I get a thank you message on the same page instead of redirecting the message to a different page as on the script here - header('Location: thanks.html'); Also I want the errors to be echoed in front of the field concerned as in name, email, subject, message <?php $myemail = "hila@gmail.com"; $name = check_input($_POST['name'], "Enter your name"); //error or success message echoed here $subject = check_input($_POST['subject'], "Enter a subject");//error or success message echoed here $email = check_input($_POST['email']);//error or success message echoed here $message = check_input($_POST['message'], "Write your message");//error or success message echoed here if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) { show_error("E-mail address not valid"); } $message = " Name: $name E-mail: $email Subject: $subject Message: $message "; mail($myemail, $subject, $message); //This is where the problem is header('Location: thanks.html'); //Want to have this message on the same page exit(); function check_input($data, $problem=''){ $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0){ show_error($problem); } return $data; } function show_error($myError) { ?> <html><head> <title> email 2014</title> </head> <body> <strong><?php echo $myError; ?></strong><br /><br /> <form class="email" action="" method="post"> <p>Name:</p> <input type="text" name="name" /> <p>E-mail:</p> <input type="text" name="email" /> <p>Subject:</p> <input type="text" name="subject" /> <p>Message:</p> <textarea name="message"></textarea></p> <input class="send" type="submit" value="Send"> </form> <?php exit(); } ?> </body></html>
  4. I can't seem to see the problem with my success and not success form below. The form is sent successfully but keep outputting oops try again <?php if ($success) { $message = "Message sent succesfully! Thank you."; } else { $message = "Oops! Try again!"; } echo '<div id="message">'.$message.'<div id="close-button"></div></div>'; ?>
  5. Hi guys, my form works fine but I want the thank you message on the same page in red font, At the moment I am redirecting to thanks.htm and my form is on contme.php, how do i do that? script below: <?php $Email_address ='sam@yahoo.com '; session_start(); $errors = ''; $name = ''; $visitor_email = ''; $user_message = ''; if(isset($_POST['submit'])) { $name = $_POST['name']; $visitor_email = $_POST['email']; $user_message = $_POST['message']; if(empty($name)||empty($visitor_email)) { $errors .= "\n Name and Email are required fields. "; } if(IsInjected($visitor_email)) { $errors .= "\n Bad email value!"; } if(empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) { $errors .= "\n The captcha code does not match!"; } if(empty($errors)) { $to = $Email_address; $subject="loverman"; $from = $Email_address; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "$name contacted you by submitting the message below:\n\n". "Name: $name\n\n". "Email: $visitor_email \n\n". "Message: \n\n ". "$user_message\n\n". "IP: $ip\n"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to, $subject, $body,$headers); //header('Location: ?success'); //echo "your enquiry was submitted successfully, thank you,"; header('Location: contme.php'); echo "Form submitted succesfully, thank you"; } else { echo "Form failed to send"; } } function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?>
  6. Thanks guys but how do I get the php echo working together with alert message? For example using both php echo $myInfo; and echo "<script> alert('Your input is correct');</script>"; maybe something like this but not so good still a newbie echo "<script type='text/javascript'>alert('$myInfo' Your input is correct);</script>"; echo "<script> alert('Your input is correct');</script>"; now where do I put my alert message as well echo "<script type='text/javascript'>alert('$myInfo');</script>";
  7. Hi guys how do I get JavaScript and php doing wonders for me. I want to chnage the following php echo $myInfo; to something like this echo "<script> alert('Your input is correct');</script>"; I am failing to make any changes here please help. I actually want javascript to output the echo $myInfo but don't know how. Thanks a lot
  8. Hi guru I meant how go I get users input to replace any badwords with symbols? My biggest problem is using input field with PHP, as a newbie I am struggling a bit so any help would be welcomed and appreciated greatly. I mean the above example for instance the badwords.text am i correct to add bad words in the file as follows: "bad1","bad2","bad3" or do I have to enter badwords this way: "bad1, bad2, bad3" I want to make sure that when user type in a bad word in the field it alerts them that thier badword will be replaced with *** Thank you once again
  9. PHPfreaks your script woks fine. However I would like to make a few modifications and apply it inside input fields, how do I do that? Lets say my input fields are as foolows: <input type='text' name='badwords' /> <!-- where do I put php on this input field as a php include file--> <?php $badwords = array('bad1', 'bad2', 'bad3', 'ass'); $text = 'This is a test. Ass. Grass. bad1.'; function filterBadwords($text, array $badwords, $replaceChar = '*') { return preg_replace_callback( array_map(function($w) { return '/\b' . preg_quote($w, '/') . '\b/i'; }, $badwords), function($match) use ($replaceChar) { return str_repeat($replaceChar, strlen($match[0])); }, $text ); } echo filterBadwords($text, $badwords); ?>
  10. Thanks again guys you are all awesome. I cant thank you enuogh
  11. Hi guys i am busy playing around with php if statements. The code below works fine as it is but I am having problems trying to gt it to work inside an input field please help <?php $number1 = "01234"; $number2 = "012345"; if($number1 != $number2) { //if they don't match output the following echo "info do not match. Please try again."; }else{ //if they match output the following echo "Info matched Successfully!"; exit(); } ?> Now how do I tweak my above php code to incorporate the code above for easy input into fields? $number1 = "01234"; $number2 = "012345"; Please help? <form method="post" name="change"> <p>Number 1 Info<br /> <input type="text" name="number1" /> </p> <p>Number 2 Info<br /> <input type="text" name="number2" /> </p> <p> <input name="submit" type="submit" value="Check if they match" /> </p> </form>
  12. Wow guys! 1439 views on this in two days is awesome. I am a php newbie and I am impressed. Hope you can all visit my website when I am finished making it lol.
  13. Thanks Thodanga and Mcgyver you guys really helped me on this. I am working on it
  14. I have tried the code and it keeps echoing password do not match, any help guys
  15. Hi guys I am having all sorts of problems with my script. I want the script to check current password before allowing member to change their password to a new one. My script is failing to check their old password and also to match their new password with confirm new password. I am still new in php and I am using mysqli please help. I will be adding security later on. <?php include_once("Mydbtable.php"); if(isset($_POST['submit'])) { $Old_pwd=$_POST['Oldpass']; $New_pwd=$_POST['pass1']; $confirm_pwd=$_POST['pass2']; $data_pwd=$fetch['Oldpass']; $email=$fetch['email']; $sql = "SELECT * FROM MembersTable WHERE email = '$email' AND password = '$Old_pwd' "; $result = mysqli_query($Mydbtable, $sql); if($New_pwd==confirm_pwd && $data_pwd==$Oldpass){ $sql = "UPDATE MembersTable SET password = '$New_pwd' WHERE email = '$email' "; $result = mysqli_query($Mydbtable, $sql); $msg="password changed"; } else { if($pass1 == "" || $pass2 == ""){ $msg= "Passwords do not match. Please GO BACK and try again."; exit(); } } ?> <form method="post" name="change"> <?php echo $msg; ?> <p>old password<br /> <input type="password" name="Oldpass" id="Oldpass" /></p> <p>New password<br /> <input type="password" name="pass1" id="pass1" /> </p> <p>Confirm password<br /> <input type="password" name="pass2" id="pass2" /> </p> <p> <input name="submit" type="submit" value="Save Password" /> </p> </form>
  16. Hi guys, I have two forms on one php page, the forms work fine if they are on different pages but I want both of them on one page to make my registration/login page look trendy and modern. However, I have come to an abrupt halt as the two forms fail to execute. One works fine and the other is ignored completely. How do I get both of them executing at different intervals even though they are on one page? I think I have a problem on the 'return false'. The registration form works fine but the login form is failing to work. I have two different ajax for processing this form please help. code of forms below, thank you. Some members suggested I try <input type="submit" /> but still no luck using input attribute. Please help //FORM 1 <div> <p style="text-align:center;;">REGISTRATION FORM</p> <form name="rgistrationform" id="registration" onsubmit="return false;"> <div>Username: </div> <input id="username" type="text" /> <div>Email:</div> <input id="email" type="text" /> <div>Enter Password:</div> <input id="pass1" type="password" /> <div>Repeat Password:</div> <input id="pass2" type="password" /> <br /> <button id="registerbtn" onclick="register()">Register</button> <br /> </form> </div> //FORM 2 <div> <h3 style="text-align:center;">LOGIN FORM</h3> <form id="loginform" onSubmit="return false;"> <div>Email Address:</div> <input type="text" id="email" /> <div>Password:</div> <input type="password" id="password" /> <br /><br /> <button id="loginbtn" OnClick="login()">LOG-IN</button> <br /> <a href="4gotpass.php"><strong>Forgot Password</strong></a> </form>
  17. I have tried that but still not working, please anyone help?
  18. Hi guys, I have two forms on one php page, the forms work fine if they are on different pages but I want both of them on one page to make my registration/login page look trendy and modern. However, I have come to an abrupt halt as the two forms fail to execute. One works fine and the other is ignored completely. How do I get both of them executing at different intervals even though they are on one page? I think I have a problem on the 'return false'. The registration form works fine but the login form is failing to work. I have two different ajax for processing this form please help. code of forms below, thank you //FORM 1 <div> <p style="text-align:center;;">REGISTRATION FORM</p> <form name="rgistrationform" id="registration" onsubmit="return false;"> <div>Username: </div> <input id="username" type="text" /> <div>Email:</div> <input id="email" type="text" /> <div>Enter Password:</div> <input id="pass1" type="password" /> <div>Repeat Password:</div> <input id="pass2" type="password" /> <br /> <button id="registerbtn" onclick="register()">Register</button> <br /> </form> </div> //FORM 2 <div> <h3 style="text-align:center;">LOGIN FORM</h3> <form id="loginform" onSubmit="return false;"> <div>Email Address:</div> <input type="text" id="email" /> <div>Password:</div> <input type="password" id="password" /> <br /><br /> <button id="loginbtn" OnClick="login()">LOG-IN</button> <br /> <a href="4gotpass.php"><strong>Forgot Password</strong></a> </form>
  19. Hi guys, You have all really helped me. I am stuck on a php5, mysqli, ajax password reset from my mysqli table called table_sers for field name usernamesand set to varchar 255. I am having problems with this script and will appreciate any elp please. I want the script t be able to validate users email address from database before allowing user to change password. I have no idea if i should put MYSQLI_ASSOC //my ph mysqli script <?php //pchange.php include_once("db_gupta.php"); // this is my database path if(isset($_POST["table_users"]) && isset($_POST["User_pass1"]) && isset($_POST["User_pass2"])){ $id = $_SESSION['userid']; $password = md5($hash_pass); $sql = "SELECT from table_users WHERE email='$email' AND password='$hash_pass' id='$id'"; $sql = "UPDATE table_users SET password ='$hash_pass' WHERE id ='$id'"; $query = mysqli_query($db_gupta, $sql); if(mysqli_affected_rows()>0) echo "Password Changed Successfully"; else echo "Invalid "; } else echo "Invalid"; ?> //Main password ajax and html script <script language="javascript"> function submitform() { var User_Id=document.getElementById("table_users").value.match("^\\S[0-9a-zA-Z.-]*$"); var User_pass1=document.getElementById("User_pass1").value.match("^\\S[0-9a-zA-Z.-]*$"); var User_pass2=document.getElementById("User_pass2").value.match("^\\S[0-9a-zA-Z.-]*$"); document.getElementById("User_pass1").value=""; document.getElementById("User_pass2").value=""; if(User_Id==null || User_pass1==null) { alert("invalid user id/password"); document.getElementById("err").innerHTML="invalid user id/password"; return; } else if(User_pass2==null) { alert("invalid new password"); document.getElementById("err").innerHTML="invalid new password"; return; } else { var str="table_users=" + User_Id + "&User_pass1=" + User_pass1 + "&User_pass2=" + User_pass2; $.ajax({ type: "POST", url: "pchange.php", data: str, success: function(output){ alert( output ); document.getElementById("err").innerHTML=msg; } }); return; } } </script> <h2>Change Password</h2> Email: <input id="table_users" name="User_Id" type="text" /><br /> Old Password: <input id="User_pass1" name="User_pass1" type="password" /><br /> New Password: <td><input id="User_pass2" name="User_pass2" type="password" /><br /> <input name="text" onclick="submitform();" type="button" value="Submit" /> <input name="text" type="reset" value="Reset" /><br /> <span id="err"></span> Thanks once again.
  20. Thank you very much administrator, you are brilliant may God bless you and if you are not a christian may Allah be with you. Can't thank you enough
  21. Hi guys, I am still stuck please help me someone. The script works fine using the echo function but I cant seem to get it to work using input, textarea fields. Also I cant seem to get it to alert user that there is a badword in their input. Thank you. <?php function BadWords($text){ //badwords to replace $allBadwords = array('badword1','dbad2','bad3','bad4','bad5'); //replaced with *** return str_replace($allBadwords,'***',$text); } echo BadWords("i like to eat lots of applepie, but my favourite thing to do is to is simply to chew on raw carrot"); ?> <input type="text" name="text"> How can i use it here <textarea> <textarea> How can i use it here <input type="submit" name="submit"> And finally how can I sue it here <p>A very long sentence here</p>
  22. Hi guys, Thanks a lot for the help so far with my college work. I appreciate that. Sorry I am stuck on the following script and need a bit of help. I want users to be able to enter details inside input and textarea fields. I want the script to stop swear words and possibly replace with better one's or better still pops an alert window stating that the user has put inappropriate words. The script must be able to count words at the same time: <?php $string = "I hate idiots"; $bads = array('swearwords.txt'); //swearwords.txt contains all the swear words foreach ($bads as $bad) { if (strstr($string,$bad) !== false) { echo 'No bad words found, please continue to submit your form<br />'; } else { echo 'You entered a bad word, try again<br />'; } } ?> <SCRIPT LANGUAGE="JavaScript"> function CountLeft(field, count, max) { if (field.value.length > max) field.value = field.value.substring(0, max); else count.value = max - field.value.length; } </SCRIPT> <form action="" method="post"> <input name="text" onKeyDown="CountLeft(this.form.text, this.form.left,50);" onKeyUp="CountLeft(this.form.text,this.form.left,50);"><!--/count here --><br /> <textarea name="text" onKeyDown="CountLeft(this.form.text, this.form.left,50);" onKeyUp="CountLeft(this.form.text,this.form.left,50);"> </textarea><!--/count here --><br /> <input type="submit" type="submit"> </form>
  23. Thanks a lot Pravins, got it working now mate
  24. i guys, I have been stuck for a few days now. My PHP programming is much better but stuck a little on a project. How do I get users to input their own website URL into my website so that they can easily be linked to my website. Below is the little code which I am failing to get users to input their own website url. I can use the code if I type in my own website before FTPing the account but that's not what I am looking for: I actually want users to input their own url for example www.mywebsite.com only and this then gets saved onto the database, which I have already, thanks a lot. Please only respond to what I am asking guys. <?php $input= "website is http://www.nameofsite.com"; //the above works fine but i want it empty so users can input their own hyperlinked urls $clickable = preg_replace('*(f|ht)tps?://[A-Za-z0-9\./?=\+&%]+*', '<a href="$0">$input</a>', $input); echo $clickable; ?> <form action="" method="POST">Update your URL<br /> Email: <input type="text" value="php url" name="email"> Website: <input type="text" value="php url" name="website"> <input type="submit" value="submit" name="submit"> </form> Thanks a lot guys Kayz100
×
×
  • 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.