Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey there, I'm a young coder!

I'm making a prototype website builder, and I have a PHP script that is able to create a sub-domain from my form.

Is there any way that I can prevent malicious users from, say, spamming the form? My HTML is as follows:
HTML
<form action="website-build/build.php" method="post">


This would allow people to know the location of the script and subsequently use the inputs as data.

These are my inputs (they are validated through HTML, I just didn't include the pattern value):

HTML
<input name="first_name" type="text" />
<input name="last_name" type="text" />
<input name="email" type="email" />
<input name="cms" type="radio" value="wordpress" />
<input name="cms" type="radio" value="drupal" />
<input name="cms" type="radio" value="joomla" />
<input name="subdomain" type="text" />


The URL would look like: ...build.php?first_name=VALUE&last_name=VALUEemail=VALUE&cms=VALUE&subdomain=VALUE

So how can I stop people from submitting this in the URL (GET) or with a tool (POST) and thereby allowing no access to said script unless used by my website?

I'm thinking the best course of action would be to hide the name attribute of the inputs somehow and then people wouldn't know.

What I have tried:

I thought about deleting the action and having the PHP run in the actual document, but that doesn't help, it does the same thing. I have yet to figure out how to remove the name attribute of the inputs.
Posted
Updated 30-Apr-17 11:55am

1 solution

Quote:
So how can I stop people from submitting this in the URL (GET) or with a tool (POST) and thereby allowing no access to said script unless used by my website?

You can't stop people from doing this.
I am not expert on this, but:
- You can consider that any client side check can be bypassed by malicious user.
- You have to recheck everything in your php script, including all the checks normally done on client side.
- Hiding the script URL will not help because the URL will be used to post the answer, and this can be detected by user.
- One of the thinks you have to check is that the user is legitimate and in a legitimate session.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900