Jump to content

684425

Members
  • Content Count

    25
  • Joined

  • Last visited

Everything posted by 684425

  1. The code in attached file is not working for me. and i am failed to find any mistake. Anyone help me please. deletedept.php
  2. Plz check attached file. it does not give any error when letters are typed. new.html
  3. <input id="numb" type="number" /> <input type="submit" onclick="myFunction()" /> <p id="demo"></p> <script> function myFunction(){ var x = document.getElementById('numb').value; var regex=/^[1-9]+$/; if (x == ""){ document.getElementById('demo').innerHTML = "Input is Missing"; } else if (!x.match(regex)){ document.getElementById('demo').innerHTML = "Input Incorrect"; } else { document.getElementById('demo').innerHTML = "Input OK"; } } /* if (x == "") { document.getElementById('demo').innerHTML = "Input is Missing"; } else if (isNaN(x)) { document.getElementById('demo').innerHTML = "Input Incorrect"; } else { document.getElementById('demo').innerHTML = "Input OK"; } } */ </script> When input type is "text" it works fine. but when i change input type to "number" and then if i type letters or letters plus numbers. it says "input missing" How can i get correct output while using input type "number" ? Please guide. Thankyou.
  4. Explained by a friend. $i = $i++; // internally is more like $temp = $i++; // $temp = 2; $i=3 $i=$temp; // $i=2
  5. Actually the question was asked in a facebook group. and my answer there was... You ignored variable $p in second code and directly called an output of $i so it became $i = 2; $i++; for php. In your 1st code you are trying to do the same thing, but because of only one variable $i on both sides in 2nd line, php ignored #YOU and did it work. 1st code $i = 2; //declared an assigned a value. $i = $i++; //another declaration. ------------------------------------ 2nd code $i = 2; //declared an assigned a value. $i++; // direct increment. Still i was confused... Thanks dear for reply
  6. <?php $i = 2; $i = $i++; echo $i; ?> Output of above code is 2. <?php $i = 2; $p = $i++; echo $i; ?> Output of above code is 3. Why this difference? I mean how these codes are processed to give an output?
  7. <a href="get.php?x=news">get1variable</a> <a href="get.php?x=news&r=links">get2variables</a> <?php $title = "Home | page"; if (isset($_GET['x'])) { if ($_GET['x'] == "news"){ $title = "News | Page"; include "news.php"; } } if (isset($_GET['x']) && isset($_GET['r'])) { //not working if ($_GET['x'] == "news" && $_GET['r'] == "links"){ //not working $title = "Links | Page"; include "files/links.php"; //confused here, because this i think is to include links.php directly, } //but i want links.php to be included in news.php } echo "<title>$title</title>"; ?> i also tried... if (isset($_GET['x'])) { if ($_GET['x'] == "news"){ if(isset($_GET['r'])) { if ($_GET['r'] == "links"){ //this also not working $title = "Links | Page"; include "files/links.php"; //confused here... } } } } Aalso for creating a function i tried to learn how to create functions. but after learning i failed to create a function for this. if someone please guide me in detail for this?
  8. session_start(); $text = rand(10000,99999); $_SESSION["vercode"] = $text; $height = 25; $width = 65; $image_p = imagecreate($width, $height); $black = imagecolorallocate($image_p, 255, 255, 255); $white = imagecolorallocate($image_p, 0, 0, 0); $font_size = 14; imagestring($image_p, $font_size, 5, 5, $text, $white); imagejpeg($image_p, null, 80); The code above creates an image with white background. How to change it to create transparent background?
  9. i have an account in skrill, they have given me an account number eg; XX12345678 which they generated automatically for me. and its unique for every registered user. i want to do the same thing for users of my site.
  10. just random looking and unique, because a registered user will need that account number to login to his account. if possible and if you guide me, i want to do it. please guide
  11. not this because it generates alphanumeric random output and i want XY(random, unique integer, fixed length) = XY9162942 or XY6433389 Sorry i forgot to mention fixed length in previous post.
  12. I am trying to create a registration form where users put their name, email and password only. but i want to write an auto generated account number into database table for each user e.g; XY1234567 where XY should not change 1234567 auto generated random number and no duplicates (in numbers only). example... XY1234567 XY2345678 XY2233455 i found code $num_of_ids = 10000; //Number of "ids" to generate. $i = 0; //Loop counter. $n = 0; //"id" number piece. $l = "AAA"; //"id" letter piece. while ($i <= $num_of_ids) { $id = $l . sprintf("%04d", $n); //Create "id". Sprintf pads the number to make it 4 digits. echo $id . "<br>"; //Print out the id. if ($n == 9999) { //Once the number reaches 9999, increase the letter by one and reset number to 0. $n = 0; $l++; } $i++; $n++; //Letters can be incremented the same as numbers. Adding 1 to "AAA" prints out "AAB". } but its not working as i want. Any help please?
  13. Please guide me how to do this? If you can share an example?
  14. <script type="text/javascript" src="clock.js"> <script type="text/javascript" src="tip.js"> both these files are in same directory along with index.php tip.jis is working fine but clock.js don't work. You said "you're using php for inline variables. You need to pass them through a parameter function instead" how can i do this?
  15. I am sorry i have posted it by mistake in php section. How can i correct it?
  16. Code works when... <script type="text/javascript"> var currenttime = '<?php print gmdate('F d, Y H:i:s', time() + (1 * 60 * 60))?>' var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December") var serverdate=new Date(currenttime) function padlength(what){ return (what.toString().length==1)? "0"+what : what } function displaytime(){ serverdate.setSeconds(serverdate.getSeconds()+1) var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+", "+serverdate.getFullYear() var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds()) document.getElementById("servertime").innerHTML=datestring+" "+timestring } window.onload=function(){ setInterval("displaytime()", 1000) } </script> Code not works when... <script type="text/javascript" src="clock.js"> I want to use second option. Any help?
  17. Someone suggested to use switch case but i don't know how to do it. any help?
  18. The same thing in a site <ul class="col-sm-2 col-sm-offset-2"> <li><a href="/">Home</a></li> <li><a href="https://secure.payza.com/login">Log In</a></li> <li><a href="https://secure.payza.com/signup">Sign Up</a></li> </ul> The site is online.
  19. I am using xampp. <a href="/">Home Page</a> The above code (when clicked in browser) takes me to the localhost instead of localhost/website How can i clear this issue?
  20. because i am poor in english, maybe i didn't get what you exactly asked. but i will try to explain what i am trying to do. URL from my last reply http://domain.com/x=account&r=news&id=345 so, x=account (include account.php) &r=news(include news.php within account.php) &id=345 (get content from database and display) i did copy that example and tried to modify it but failed. because i am new to php. also i found a (mistake?) in your example. //variable $pages not defined. //i changed $pages to $links and it worked fine. if (isset($_GET['x']) && in_array(trim($_GET['x']), $pages)) { What i wanted is ... <a href="get.php?x=news">get1</a> <a href="get.php?x=updates">get2</a> <?php $title = "Home | page"; if (isset($_GET['x'])) { if ($_GET['x'] == "news"){ $title = "News | Page"; include "news.php"; } elseif ($_GET['x'] == "updates"){ $title = "Updates | Page"; include "updates.php"; } } echo "<title>$title</title>"; ?> but this is for GET x only. how can i add GET r ?? I am using a database dear. I have explained above.
  21. I did not know there is a time limit for editing a post. (misunderstanding sometimes because i am weak in english) The question was, i want to make URLs like; http://domain.com/x=home http://domain.com/x=account&r=profile http://domain.com/x=account&r=news&id=345 http://domain.com/x=account&r=updates&id=567 x is used for navbar and r is used for any content on account page. I asked that can it be done using php only.? without any database connection.
  22. I have the following three links in same page. http://localhost/folder/file.php?x=link1 http://localhost/folder/file.php?x=link2 http://localhost/folder/file.php?x=link3 i want to show URLs as they are... link1 is to include a file named "x.php" link2 is to include a file named "y.php" link3 is to include a file named "z.php" Can it be done in php only? PS: its not about creating hash ids. and i want to do it without any sql db connection.
×
×
  • 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.