Jump to content

Recommended Posts

The use of $_REQUEST is not recommended. It is far safer and better to use what you actually expect your data to arrive in. If the form uses method='POST', then use $_POST. Same if it is a GET request. Use $_GET. Hackers could do something with a get while your script expects a POST and by using $_REQUEST they can still get into your script. Why use the ambivalent $_REQUEST when you know what it should be?

 

If English is your primary language, why do you write such poorly composed posts?

Edited by ginerjm
I was using a  php form generator, and had noticed it uses .$_REQUEST

 

 

just because you saw, found, or bought something on the Internet doesn't mean it's the correct way to write code. there's a ton of crap code to be found on the web that was written by people that never learned the actual reason for doing things and are more concerned with click revenue and things they can get you to buy on their site than the quality of the code they are posting/selling.

As to Ginerjm, I am not wisecracking. You say people are helping me, but even you said when I put up $_post, you even responded me this when others said to use that. Which has confused me greatly of what to even use, since I tried echo, $post, $_post,and $_get. And a couple people are saying don't use that use this. It would have been simpler to just put an example of just one line to help me to start off with and figure the rest from there. I am trying to learn the basics of the script and I am more of a visual learner and try to learn by seeing it. That is why I posted little script parts even if not correct, to try to get it to show up from the html form to the .php page in the same format as the form. I have progressed a little and had some things show up on the php page but not of what I was intending to have done, and instead it posted a line or two of php script on the page of echo'ing it even when post tag was used. Plus by using the parts of php, I am trying to see what each one does as to learn. When I had my game website with html, I learned it myself by breaking down other websites into code and figured out a majority of the code about 10 years ago. I am trying to do the same with php so I can get a better understanding of what the code is doing even at the smallest parts. Such as echo'ing a person's first and last name onto a page and such.

 

1 - Turn on php error checking. It will help you. (See my signature)
2 - Hint - there is no such variable as $_post. A little bit of php knowledge will teach you that.
3 - Proper array syntax is $variable['index'] which you are not doing.
4 - You are doing a form POST so why the use of (incorrect) $_get references?

the data from a post method form will be in $_POST variables, with that exact capitalization and with the under-score, which is what Ch0cu3r first gave an example of in reply #12 in this thread. this is not the same as $_post. php variables are case-sensitive, which you would have known if you had studied the prerequisite basics of the php language. the capitalization we are typing when it comes to the actual php code elements we are showing you is not there for emphasis, it's there because it is required.

 

programming is an exact science. every letter in every line of code matters and in this case, the letter-case of those letters matter.

i suspect you are referring to these -
 

some tips -
 
1) you would dynamically produce the form, rather than writing out all that repetitive markup. you would either allow the user to enter (an input box) or select (a select/option dropdown) the number of fields to produce or you would display a base number of fields and have an 'add' button that would dynamically add more fields.
 
2) form fields need a name='...' attribute to cause the data to be submitted. for sets of data, you would use an array for the name so that you can process the data using php's array functions. see this link for using an array for form fields - http://php.net/manual/en/faq.html.php#faq.html.arrays

 
 

(and i as stated, you should let the computer write out multiple same meaning form fields.)

 
 

(and as i wrote above, you should be letting the computer do the repetitive work of creating the form fields and processing the form data, rather than you writing out all this code.)


all of these state that the form/form fields would/should be dynamically produced/created.
 
the point of a web server-side scripting language, like php, is to dynamically produce web pages, so that the web page can be flexible and dynamic in what is does, but it also eliminates the need for the person creating the web page to write out block after block of repetitive html markup or repeat the same content on multiple pages. php is not just for processing form data. it is used to produce anything that makes up a web page - html, css, javascript, and media files.

 

in this thread, you have written out 20-30 sets of form fields, twice. once without name attributes, then a second time with. and there are a ton of missing and inconsistent markup/labels in those sets of form fields that at some point you will need to fix. you have also written out nearly 30 php echo statements.

 

DRY - Don't Repeat Yourself. this means that you should not repeat what you do. let the computer generate the multiple sets of repetitive/same meaning form fields and let the computer process all the submitted form data by looping over it. using php, you can write one set of form fields (i.e. a template of what you want), then use a loop in your code to produce as many fields as you want. by having the the card quantity and card name form fields defined only once, it will now be easy to fix any errors or make any changes in those form fields. you only have to do it once, not 20-30 times.

 

and as i also stated, the number of fields you produce can come from the following, dynamically, at runtime -

 

you would either allow the user to enter (an input box) or select (a select/option dropdown) the number of fields to produce or you would display a base number of fields and have an 'add' button that would dynamically add more fields.

 

 

 

as also stated, by using an array for the form field name (see the link i provided), the form data will be submitted to php as an array. you can write a simple loop to process all the data, no matter how many form fields there are.

Is there a way to make placeholder that works in conjunction with the api as to allow the user to type letters and to possibly auto fill?

Or show multiple selections similar to a drop down box such as a person typing Forest and part way of typing (for), that it shows forest and every other card name that begins with for unless user selects forest or continues typing the word?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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