So I recently made a website, and I have two questions I need answering.

The first is I have a form with multiple things in it (text fields, checkboxes and buttons). Now I want the form to check if the checkbox has been checked or not, and I have come up with this code:

<?php if(isset($_POST['Agree'])){
Redirect to page
}
else
{
echo 'You must agree to the terms.';
}
?>

As you can see, I'm stumped as what to do. Where would I put this? Right at the top where I start the form, or where the button is to submit the form?

The form begins with:

<form enctype='multipart/form-data' action='create-user.php' method='post'>

Help me please.

The second question is that users are created and put into an SQL database. Currently they appear as domain.com/123456 where 123456 is the username, and these have been crawled by google, which is BAD! I was thinking of somehow protecting these from being indexed, but I have no idea. Any help here? Thanks.

You should try using javascript for example

lets assume the id of the checkbox is "chec"

function check(){

if (document.getElementById("chec").checked){


//anything you want it to do

}else{

//anything you want it to do
}


if you must use php the codes must be on the page your submitting the forms to

<?php if($_POST!=""){

}

else

{


//Redirect to page
}

?>

The code at the top should go into the file 'create-user.php'. For the second question you can specify files that you don't want indexed in a robots.txt file. Google 'robots.txt' for more info on that :)

Thanks for answering question number 1, it worked :)

I've done the robots.txt thing, but I don't know what I'd specify as the usernames are stored in an SQL database, and I don't want to disallow indexing of everything.

Have you tried putting the meta tag in the pages you don't want indexed?

<meta name='robots' content='noindex' />

That would be the ideal solution because you could keep the whole folder '/users' in the robots.txt file as nofollow. I would like to help but I don't really know how your site is structured or how it works. If you want to PM me I will do my best to help you out with moving everything over to a /users folder :)

Member Avatar for deleted1234

For you to put all your users into domain.com/users/123456 you just have to create another folder from your root directory named "users" and put all your user scripts in that folder. That way, whenever you show their profiles you would have to index domain.com/users/123456. That's the only way I think that can be possible.

Another solution is for you to contact Google directly through their website removal page or webmaster tool.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.