I am using swf-upload to allow users to upload images quickly. I need them to be able to select which galleries they want them to appear in so I have added extra controls to the form - but they are never passed in GET or POST to the upload.php catcher.
I think 'addPostParam' is what I need to set, but am not entirely sure where or how and I can't find any guide that is clear on the issue.
Also is there any problems using PHP style array names for the tags such as tag[1] tag[2] etc?
Flash can't yet send multiple data at once in easy way. Send image in RAW data then you can give it name. Change that name to name+GET. Sample: image.jpg?property=value;
Related
Question about GET and POST in PHP. i wonder what is the difference between POST and GET and when do you use them respectively?
so as far from i tried, GET can also show the data in the link.
for example, the name of my link is Localhost/index.php then inside my php file is an input box and a submit button. if for example i use GET, if i click the submit button, it will take the data i put in inputbox(for example, name) and add it to the link. so the link now is Localhost/index.php/?name=Tina i think this is how GET works. but if i use POST, it will not show the input data in the link and it will remain Localhost/index.php. (atleast, from what i practice)
i wonder what are other differences between the two and when they should be use? for example im making a website(ex: sign up website) that will take information and send it to a database in MySQL..or the webpage should carry over the from this webpage to another webpage. should i use GET or POST?
You are kind of overthinking it. It is as simple as:
POST - used to post(send) data to the database.
GET - used to get(fetch) data from the database.
So in the case of the form, what you need to do is a POST request, so you send the data to MySQL. And in order to retrieve that data, you will perform a GET request.
See this https://www.geeksforgeeks.org/http-get-post-methods-php/ for a comprehensive explanation.
Keeping it very short:
You never-ever should pass any sensitive information over GET method, because it's visible by logs, by your internet provider/router, third parties.. such as google analytics and more.
A common use of GET is when you allow users to change the parameters of a page they see.. i.e. search parameters or the number of products per page.
POST when you want to send information to the server "privately" and (preferably) with a nonce to make it sendable only once.
But regardless of a method - POST or GET - sanitise, sanitise, sanitise.. that is what you need to really worry about. User input should not be accepted as is when you receive it, kinda #1 rule on the internet.
I need help in identifying how I should set up this non public website.
Basically there are around 2000 images referenced in a database.
Each user will be able to check or uncheck each image with the use of a checkbox.
Some users might have different images checked or unchecked.
I want the checkbox to process an AJAX request to a user specific XML (PHP generated from the db) which contains a boolean variable for each image entry.
The PHP then references the XML and highlights checkedboxes and disables the uncheckedboxes.
Again each user will have different references for each image.
Im not sure if the above is the correct method to use.
I want the page to dynamically load the first 20 images and if the checkbox is changed, instantly updated and refreshed without a page reload. Then I'll paginate to the next 20.
If I'm on the right track I'll attempt a demo and post an update.
Thanks,
Depends how you want to do it. You'll need to brush up on your javascript as well to track the on change event. If you're bring in the images with ajax to begin with I would create an object for each and attach the event to element. Then on click you could post the image_id or what have you to the server. Alternatively you could use an attribute on the checkbox/image like data-imageid="1"
JSON or XML, both will work, it just depends how you want to design it. Though from my experience I would use JSON instead.
The JSON array you would return might look something like {1:true,2:false,3:true} etc, so foreach key value pair you would either check it be it true or not on false.
Consider editing your tags for javascript or jquery to see if you get some better answers. Or I could elaborate further if I'm on the right track.
I am trying to do something really basic but can not seem to find a tutorial for it.
I have created a simple web form using HTML what I need todo is create a php file that will read the web form, open a new browser window (or display in same page) the contents of the web form, do toy guys have any tutorials on this?
Many thanks
Chris
I'm sure many will post different links to tutorials that they like, but I thought I would just give you the basic. The key parts to the form are the method and action. The Method attribute tells ths browser how to submit the data, either through GET or POST. The action attribute tells the browser where to submit the form. (In your case it will be, somepage.php) If you ever need the form to submit back to itself, you can here use explicitly type the page name or you can use use PHP to dynamically insert the page name. Finally, make sure that all your form fields use the name attribute, as this is how php will access the elements.
On the php side of things, your form variables will be stored in either $_GET or $_POST depending on how on method you used to submit your form. For example, assume you have a input element of type text with the name 'FirstName'. Within php you can access this by doing
<?php
var firstName = $_GET['FirstName'];
?>
This should be enough to get you started. Be sure to check out the php docs and the other tutorials listed on this page for a more details.
Please look at this tutorial: http://www.learnphp-tutorial.com/HtmlForms.cfm
And you can find many more tutorials if you search it on Google.
This should help : http://www.php-mysql-tutorial.com/wikis/php-tutorial/php-forms.aspx
I have a form which I'd like to share between 2 different websites. The form is submitted and the data is entered into the database.
Right now each website has its own copy of the script and its own database, so when I want to make updates to the form, I have to make those changes twice. Is there a way to share the form between the 2 websites, yet make it look like its being served by each website like normal. I'm also wondering if it's possible to make all the data go to one database.
The basic options would be...
You could use an html iframe to show the same form on multiple websites.
You could copy the form code between sites
If both websites are on the same server, you may be able to get a php include to include the form (this is possible in some cases even if they are not)
You can certainlly get the database to share information, just ensure the user you use to connect to it is allowed to connect from anywhere - not just localhost and you can connect to the database remotely.
You could include the form inside the other website as an iframe.
There is a short tutorial here on howto do that.
In case the form is displayed inside a whole complex page i recommend placing the form inside its own page and iclude it in both websites using an iframe.
depends what you are looking for, if you use the same process script behind it, do what Mouhannad said, and add a field "return_url" so you come back on the right page.
if it is that you want to send the fields to 2 different locations, create a proxy script and post it by a curl to both locations.
you can simply make both forms (in both websites) point to the same php page (in one of the websites)
<form action="http://www.example.com/action.php" ... >
Then check for the url reference to send the user back to the same page
The user won't feel any difference and you will have the database connection in one place
good luck!
Edit:
I thought your main concerns were the backend code since you mentioned the database. You could use iframes as suggested by the others but I always try to avoid them as much as I can. You can find lots of material online about why you should avoid them.
The other solution is use cURL to get the form's html code from the external page and keep using my above suggestion to change the action url path. This way you have the same code both for the backend and frontend. The downside is that you are making an additional request to get the form's html code which adds to the performance of your website - caching should improve that!
You can use CURL to simulate form submitting on another host, just send POST request with $_POST data.
How do i repost post data, so that i can generate a print preview of a page, by applying a different style sheet. GET is not an option as the data can exceed url length limit.
Here is the premise, FORMPAGE posts data to RESULTSPAGE, RESULTSPAGE has a print preview button which reloads the RESULTSPAGE page and applies the print style sheet, so that the user can see the preview in the browser before printing. Currently I was Passing the form data via GET (resultspage.php?value=print&data=data), however this won't do for larger amounts of data.
The manual option is to collect all the post data and pass the data through hidden form fields or perhaps use CURL, although I cant seem to visualize how that will work.
JSP has a Request Dispatcher, i guess
I think this article might help you switch the stylesheets : http://www.alistapart.com/articles/alternate/ See the setActiveStyleSheet() function
rather than reposting data you could just switch the stylesheet on-the-fly with javascript http://www.kelvinluck.com/2006/05/switch-stylesheets-with-jquery/
I think that the previous two answers are both solid ideas if all you are doing is really just switching stylesheets. PHP cannot interact with this data one it has sent it back to the server without storing it in some way. So you can have it all come back via hidden input fields as you described, store the value in the session waiting for the response to return, but these are all pretty odd solutions.
If all you are doing is switching out the stylesheet then you should try what the previous answers suggest, if you need to change other pieces then I think the best way to go would be to put the data inside of hidden fields.
PS CURL won't really help you out in this situation, nor will JSP, the interaction you're looking for is happening client side, not server side.