11
Dave_L
Re: Please help, i have to finish this. about getting input from user
  • 2005/3/30 6:47

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Don't forget to sanitize the user's input. Here's an easy way of sanitizing a value that's supposed to be numeric:

$number = @intval($_REQUEST['number']);

12
davidthomas1
Re: Please help, i have to finish this. about getting input from user

yes, the code I mentioned is just a simple way of doing it. I just wanted to express the basic principle. It would be a good idea to add validation routines to check the user input.

BTW, I discovered how to quote code in the XOOPS forum! you can just enclose the code in code /code blocks with "[" and "]" characters around the code tags (xoops codes?)

hooray for XOOPS I love it

13
buffalo
Re: Please help, i have to finish this. about getting input from user
  • 2005/3/30 9:58

  • buffalo

  • Just popping in

  • Posts: 33

  • Since: 2005/3/26


Hi, sory i couldnt make them work, they have errors i add < and > to the places but always i'm haveing errors. do u have any idea ?

14
davidthomas1
Re: Please help, i have to finish this. about getting input from user

I just tested them both :

<?
//$number = $_REQUEST['number'];
//$filename = $number.".html"; //add filename extension
$filename="test1.htm";
if (
$filename!=""//if number is not blank
{

echo 
"<script language="JavaScript"type="text/javascript">" ."window.open($filename,'','top=0,left=0,screenY=0,screenX=0,width=775,height=500,scrollbars=yes');"
."</script>";
}
else
{
echo 
"Invalid Number";
}
?>


and

<?
//$url= $_REQUEST['number']; //get form field result
$url="test1";
$ext ".htm"//file extension
$title "Window Title"//window title
$details "height=300,width=300"//window properties
$url=$url.$ext//make filename

print "<SCRIPT language="javascript">
   window.open(
$url$title$details);</SCRIPT>"
?>


It's odd. It prints the function alright but doesn't actually activate it. anyone know why?

15
davidthomas1
PHP and javascript popup window

I couldn't get the popup window to work via PHP

BUT

I just realised, you can do the same thing using just javascript. You don't need to use PHP.

This is the same thing using javascript.

<script type="text/javascript">
<!--
function 
popup()
{
 var 
url=document.forms[0].elements['number'].value;
 if (
url!=""){
   
url=url+".htm";
   
window.openurl"Window Title","status = 1, height = 300, width = 300, resizable = 0" )
   }
 else{
   
alert("Invalid number");
   }
}
//-->
</script>

<
form>
<
input type="text" name="number" size="20">
<
input type="button" onClick="popup()" value="Go!">
</
form>

16
buffalo
Re: PHP and javascript popup window
  • 2005/3/30 21:02

  • buffalo

  • Just popping in

  • Posts: 33

  • Since: 2005/3/26


Hi, thx to everybody but i need a working code, none of these are working they have errors that i cant fix them. Please give me a working code php or java it doesnt matter, i need only working one thx. it work when i use it in same window but it doesnt work when i use the codes fo popup. And is it possible to add a message when there is no page ?
and when i use the last java script where do i place the files ? and and and.. with that script whatever i write it says invalid number. if i press enter it refreshs the page
and writes www.mywebpage.com/?number=12245 in the address bar..

17
davidthomas1
Re: PHP and javascript popup window

just put all that javascript in a custom block, save it as HTML. I tested it myself. It works.

18
buffalo
Re: PHP and javascript popup window
  • 2005/3/31 9:19

  • buffalo

  • Just popping in

  • Posts: 33

  • Since: 2005/3/26


yes, it works but whatever i write there it says wrong number. where is the file location? i put the html files in root folder. also i tried themes folder but it didnt work.

19
davidthomas1
Re: PHP and javascript popup window

Is the URL extension correct?

Are you using .htm files or .html files?

The javascript code is set to use .htm files.

You can change the extension value where it says url=url+".htm"; change to url=url+".html";

It works with the files in the XOOPS root folder but you could change it to a different folder by writing:

url="http://www.mysite.com/xoops/html/"+url+".html";

if you like.

20
buffalo
Re: Please help, i have to finish this. about getting input from user
  • 2005/3/31 10:41

  • buffalo

  • Just popping in

  • Posts: 33

  • Since: 2005/3/26


url="http://www.maykopelektronik.com/"+url+".html";

i used this code but it still says wrong number, i put 1.html in root folder.

Login

Who's Online

226 user(s) are online (136 user(s) are browsing Support Forums)


Members: 0


Guests: 226


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits