1
buffalo
Please help, i have to finish this. about getting input from user
  • 2005/3/27 18:50

  • buffalo

  • Just popping in

  • Posts: 33

  • Since: 2005/3/26


let me explain, i will create a custom block will be named search but i wont search, when someone input numbers like 123 it wil open a popup window that named 123.html please help me to do it. i can make a form and a button but i dont know how to read the input value and use like this target=inputvalue.html is it possible or how can i do that ?

2
Herko
Re: Please help, i have to finish this. about getting input from user
  • 2005/3/27 19:31

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


That is not easily done, as the system would have to create a file based on the input of the user, and then display that file? Or doesn the file already exist? Again, this is not an easy quick thing to do...

Herko

3
buffalo
Re: Please help, i have to finish this. about getting input from user
  • 2005/3/28 16:54

  • buffalo

  • Just popping in

  • Posts: 33

  • Since: 2005/3/26


the file allready will be there, i'll upload files. i want to make a service part control. i coudnt find any module to do it. i have an electronic company. i give my customers a service control paper that has a number on it. With my web site all i want is decrease my telephone traffic. the customer will come to my site and will check with number and learn info about their part. i'll upload the files every day like 123.html, 124.html, 125.html. if the file doesnt exist, the file wrongnumber.html will appear. Can i make this or is it better to try makeing a module to do it? but i dont know coding in php as much as makeing a module. Sory for my english if made mistake. thx for your support.

4
buffalo
Re: Please help, i have to finish this. about getting input from user
  • 2005/3/28 20:19

  • buffalo

  • Just popping in

  • Posts: 33

  • Since: 2005/3/26


it is very important to me please someone help me !

5
buffalo
Re: Please help, i have to finish this. about getting input from user
  • 2005/3/29 10:32

  • buffalo

  • Just popping in

  • Posts: 33

  • Since: 2005/3/26


Quote:

Herko Coomans wrote:
That is not easily done, as the system would have to create a file based on the input of the user, and then display that file? Or doesn the file already exist? Again, this is not an easy quick thing to do...

Herko



hey where are you, i am waiting your answer here :). i'm looking this forum in every 30mins.

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

So you basically want to create a custom block and open a window based on user input?

The user enters a number (e.g 123) and then you want to open a pop-up window with that file displayed (e.g 123.html)

Is that right? It's a little hard to understand what you're trying to do...

You'll need to create a php file to process the form results.

In the HTML form you set action="processform.php" or such like.

I'm no expert, but, in it's most simple form, it might look like this :
the form:


<
form method="post" action="processresults.php">
  
Number:<input name="number" type="text"/> </br
  <
input type="submit" />
</
form>

the form processing script ("processresults.php") :

?>
  $number = $_REQUEST['number'] ;

   if ($number!="")
   {
    header( "Location: http://www.example.com/".$number.".html");
   }
?>

You could also use javascript to open a custom sized window but you'd need to make the PHP interact with client-side javascript.

in any case, to reference a form variables value in a PHP script, you can use $variable = $_REQUEST['formvariable'];

7
buffalo
Re: Please help, i have to finish this. about getting input from user
  • 2005/3/29 17:19

  • buffalo

  • Just popping in

  • Posts: 33

  • Since: 2005/3/26


thx, i'll try to do it. And back here to tell u, i could or not :P

8
buffalo
Re: Please help, i have to finish this. about getting input from user
  • 2005/3/29 19:07

  • buffalo

  • Just popping in

  • Posts: 33

  • Since: 2005/3/26


thx, thx, thx. it works!! realy thanks. but i couldnt add something to open popup window, and tried else to wrong or unused pages but it didnt work.
?php
$number = $_REQUEST['number'] ;
if ($number!="")
{

header( "Location:http://localhost/".$number.".html");
}

else
{
header( "Location:http://localhost/nopage.html");
}
?

i tried this, it works with true numbers but when inserting a number which is not on the server the else part is not working. how can i do it ? and i want the pages are in a popup window not in the same page. is it possible ?

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

You'll need to use Javascript to open a pop-up window.

Change the processresults.php file to this :
<?

$number $_REQUEST['number'];
$filename $number.".html"//add filename extension

if ($number!=""//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";
}
?>

I can't test it myself, but that may work.

If you want to check if the file exists first, not just for an empty number, you'd need to do a file_exists check first.

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

This may work too:
<?

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

if ($url!=""//if url is not blank
{
   
$url=$url.$ext//make filename
   
print "<SCRIPT> window.open($url$title$details) </SCRIPT>";
}
else
{
echo 
"Invalid Number";
}
?>

Login

Who's Online

209 user(s) are online (129 user(s) are browsing Support Forums)


Members: 0


Guests: 209


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