Jump to content

Submit form to "p=upload&doupload


br3nn4n

Recommended Posts

Hey guys,

 

Haven't been to the forum in a bit, looks good! I'm trying to figure out how to do this. I have a site that simply goes to whatever page based on what the "p" variable is in the query string. So, for instance if I want the upload page, I go to "http....../?p=upload"

 

Make sense?

 

Well that "p=upload" tells it to read the contents of the txt file named "upload". I know, not super secure but that's assuming someone can find the folder the txt files are stored in.

 

Anyway, I want to submit a form to that page, the "p=upload" one. The p is obviously a GET variable, but I need to submit a form via POST, to upload a file.

 

I can't think what to set the form's "action" attribute to so that it will trigger the PHP code (the part that actually does the upload) which is at the top of the "upload.txt" file.

 

I hope that makes sense! Any tips....as always, appreciated! :)

Link to comment
https://forums.phpfreaks.com/topic/198572-submit-form-to-puploaddoupload/
Share on other sites

If you can edit the upload script just add this (Assuming the element name of the one u want is a lowercase p):

$_GET['p'] = $_POST['p'];

 

Otherwise you will need a little javascript to actually submit the form to a custom url rather than the one specified in the action attribute of the form element.

 

-cb-

Answering to your question: you can set form's action attribute to either your url  http....../?p=upload  or have the "p" parameter passed as hidden field value, then within PHP script do as ChemicalBliss suggested.

 

Version 1:

<form method="post" action="http....../?p=upload">
...
</form>

 

Version 2:

<form method="post" action="http....../">
<input type="hidden" name="p" value="upload">
...
</form>

u can do one thing..

write the code in a single php file(page1.php) and put the form action as the page2.php

 

the page2.php should be some thing like this

<?php

include("page1.php");

?>

 

so by this u are calling the entire page1.php again..

hope this works

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.