thecjgcjg
Veteran Member
Posts: 1,459
| Likes: 1,130
|
Post by thecjgcjg on Jan 21, 2013 20:12:37 GMT
Ok. Basically I have this code
<html> <head> <title>Schematics</title> </head> <body> <h2>Download Schematics</h2> <form method="post" action="<?php echo $PHP_SELF;?>"> Schematic Name:<input type="text" size="12" maxlength="12" name="sname">:<br /> <input type="submit" value="submit" name="submit"><br /> </form><br /> <?php $sname = $_POST["sname"];
I want a user to be able to enter something in there to become the variable $sname
Then i want that Variable to call this script:
<?php header('Content-Type: text/yaml'); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Thu, 01 Jan 1970 00:00:01 GMT"); header("Access-Control-Allow-Origin: *"); $file_name = '$sname.schematic'; $file_path = 'Plugins/WorldEdit/Schematics'; $bhttpd_url = 'http://xxx.xxx.xxx.xxx:11111/'; $bhttpd_password = 'HiddenPassword'; $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL=>sprintf("%s%s%s/?password=%s", $bhttpd_url, $file_path, $file_name, $bhttpd_password), CURLOPT_TIMEOUT=>5.0 )); curl_exec($ch); curl_close($ch);
Which would then download the Schematic. Atleast Thats The Idea.
In Practice No. I am hoping it should be obvious what i am trying to achieve here.
But i cant make it call that script to download the file.
Any Help Appreciated. Thanks
-thecjgcjg
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 21, 2013 20:17:22 GMT
I didn't know you knew PHP
|
|
thecjgcjg
Veteran Member
Posts: 1,459
| Likes: 1,130
|
Post by thecjgcjg on Jan 21, 2013 20:20:09 GMT
I didn't know you knew PHP I thought i showed you some scripts before?
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 21, 2013 20:22:47 GMT
nope, you didn't.
|
|
thecjgcjg
Veteran Member
Posts: 1,459
| Likes: 1,130
|
Post by thecjgcjg on Jan 21, 2013 20:26:29 GMT
the second bit of that isnt mine, Ive only slightly changed it but it's Madgeeks
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 21, 2013 20:28:53 GMT
oh ok
|
|
thecjgcjg
Veteran Member
Posts: 1,459
| Likes: 1,130
|
Post by thecjgcjg on Jan 21, 2013 23:40:06 GMT
ok been trying for hours now, I have got no where. Is it even possible to just have it wait until I click submit to run the second script
|
|
Prozza
Veteran Member
Retired Developer
One does not simply clone TFM
Posts: 1,926
|
Post by Prozza on Jan 22, 2013 0:02:31 GMT
You prob want
$sname = $_POST["sname"];
On the second script.
|
|
thecjgcjg
Veteran Member
Posts: 1,459
| Likes: 1,130
|
Post by thecjgcjg on Jan 22, 2013 18:10:33 GMT
Ok, This Doesnt Work, Im Completely Lost
<html> <head> <title>Schematics</title> </head> <body> <h2>Download Schematics</h2> <form method="post" action="<?php echo $PHP_SELF;?>"> Schematic Name:<input type="text" size="12" maxlength="12" name="sname">:<br /> <input type="submit" value="submit" name="submit"><br /> </form><br /> <?php $sname = $_POST["$sname"]; $file_name = '$sname.schematic'; $file_path = 'Plugins/WorldEdit/Schematics'; $bhttpd_url = 'xxx.xxx.xxx.xxx:11111'; $bhttpd_password = '1145';
$ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL=>sprintf("%s%s%s/?password=%s", $bhttpd_url, $file_path, $file_name, $bhttpd_password), CURLOPT_TIMEOUT=>5.0 )); curl_exec($ch); curl_close($ch);
I cant make it wait. I get the feeling im going to have to do in the URL but i dont have any kind of idea how to do that.
|
|
Prozza
Veteran Member
Retired Developer
One does not simply clone TFM
Posts: 1,926
|
Post by Prozza on Jan 22, 2013 19:32:45 GMT
Well, what's happening is that when you first load the page; you haven't set any post-parameters, and therefore $sname is empty. You should probably use an if statement to validate so. There's also an error in your file naming.
<html> <head> <title>Schematics</title> </head> <body> <h2>Download Schematics</h2> <form method="post" action="<?php echo $PHP_SELF;?>"> Schematic Name:<input type="text" size="12" maxlength="12" name="sname">:<br /> <input type="submit" value="submit" name="submit"><br /> </form><br /> <?php if (!isset($_POST["$sname"])) { die(); }
$sname = $_POST["$sname"]; $file_name = "$sname" . "schematic"; $file_path = 'Plugins/WorldEdit/Schematics'; $bhttpd_url = 'xxx.xxx.xxx.xxx:11111'; $bhttpd_password = '1145';
$ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL=>sprintf("%s%s%s/?password=%s", $bhttpd_url, $file_path, $file_name, $bhttpd_password), CURLOPT_TIMEOUT=>5.0 )); curl_exec($ch); curl_close($ch);
|
|