Jump to content

Want to submit data to mysql and also have radio buttons redirect to appropriate page


rawkinyeti

Recommended Posts

Ill start this off with a "I'm not sure if this post is in the right section"....I'm building a site for my university for property registration, like bikes, ipods and what-not. I had a vision of how this site should run, and I'm a little stumped. Ive been banging my head against the keyboard for a couple days now. Ill link what codes i have done at the bottom. Right now there are five or six different html files in this "site". Right now I'm working with xampp to test until everything is completed. Initially when the user wants to register the are directed to the front page. They will post relevant information and the data will be uploaded to our sql database for safe-keeping. On this initial site there is a group of radio buttons that are all different options. For example, one is for registering a bike, next on is for registering a laptop, so on and so forth. What i want to do is when the user presses the submit button their data will be transmitted to the database via php, and i want to have those radio buttons determine which html file it should load next. Ive google around and i know i can have this done, but i just cant figure out how. I'm still pretty green when it comes to html and php and even greener when you throw javascript at me. In a couple of test pages i have done Ive been able to make the data show up in my database but no redirection, or i get the redirection right and no data. Also can this be done in the same submit button? I think this is kind of where Ive run aground. Any help would be super appreciated.

<html><head>	<title>Property Registration</title>	<style type="text/css">body{background-color:#d0e4fe;background-image:url('/crestlogofinal2.jpg');background-repeat:no-repeat;background-position:top;}</style><script>function check(){	var lastname = document.personal.lastname;	var firstname = document.personal.firstname;	var phon = document.personal.phon;	var email = document.personal.email;		if (email.value == "")	{		window.alert("Please enter a valid e-mail address.");		email.focus();		return false;	}		if (phon.value == "")	{		window.alert("Please enter a valid phone number.");		phon.focus();		return false;	}		if (lastname.value == "")	{		window.alert("Please enter a valid Last Name.");		lastname.focus();		return false;	}		if (firstname.value == "")	{		window.alert("Please enter a valid First Name.");		firstname.focus();		return false;	}		if (email.value.indexOf("@", 0) < 0)	{		window.alert("Please enter a valid e-mail address.");		email.focus();		return false;	}		if (email.value.indexOf(".", 0) < 0)	{		window.alert("Please enter a valid e-mail address.");		email.focus();		return false;	}			return true;}</script></head><body><br /><br /><br /><br /><h2><center>Property Registration</center></h2><p><center>Register your Property with the University of Maine Department of Public Safety.</center></p><form name="personal" method="post" action="report1.php" onsubmit="return check();"><fieldset><legend><b>Personal Information</b></legend>Last name: <input type="text" id="lastname" name="lastname" />         First name: <input type="text" id="firstname" name="firstname" /><br />Student Id Number: <input type="text" id="studentid" name="studentid" /><br /><br />Address: <input type="text" id="address" name="address" /><br />City: <input type="text" id="city" name="city" /><br />State: <select name="state" id="state" size="1">	<option value="AK">AK</option>	<option value="AL">AL</option>	<option value="AR">AR</option>	<option value="AZ">AZ</option>	<option value="CA">CA</option>	<option value="CO">CO</option>	<option value="CT">CT</option>	<option value="DC">DC</option>	<option value="DE">DE</option>	<option value="FL">FL</option>	<option value="GA">GA</option>	<option value="HI">HI</option>	<option value="IA">IA</option>	<option value="ID">ID</option>	<option value="IL">IL</option>	<option value="IN">IN</option>	<option value="KS">KS</option>	<option value="KY">KY</option>	<option value="LA">LA</option>	<option value="MA">MA</option>	<option value="MD">MD</option>	<option value="ME">ME</option>	<option value="MI">MI</option>	<option value="MN">MN</option>	<option value="MO">MO</option>	<option value="MS">MS</option>	<option value="MT">MT</option>	<option value="NC">NC</option>	<option value="ND">ND</option>	<option value="NE">NE</option>	<option value="NH">NH</option>	<option value="NJ">NJ</option>	<option value="NM">NM</option>	<option value="NV">NV</option>	<option value="NY">NY</option>	<option value="OH">OH</option>	<option value="OK">OK</option>	<option value="OR">OR</option>	<option value="PA">PA</option>	<option value="RI">RI</option>	<option value="SC">SC</option>	<option value="SD">SD</option>	<option value="TN">TN</option>	<option value="TX">TX</option>	<option value="UT">UT</option>	<option value="VA">VA</option>	<option value="VT">VT</option>	<option value="WA">WA</option>	<option value="WI">WI</option>	<option value="WV">WV</option>	<option value="WY">WY</option></select>     Zip Code: <input type="text" id="zip" name="zip" /><br /><br />Phone Number: <input type="text" id="phon" name="phon" /><br />Email Address: <input type="text" id="email" name="email" /></fieldset><br /><input type="radio" name="reg" id="bike" value="bike.html" /> I want to register a Bike. <br /><input type="radio" name="reg" id="laptop" value="computer.html" /> I want to register a Laptop. <br /><input type="radio" name="reg" id="ipod" value="Ipod.html" /> I want to register a Ipod. <br /><input type="radio" name="reg" id="phone" value="phone.html" /> I want to register a Phone. <br /><input type="radio" name="reg" id="camera" value="camera.html" /> I want to register a Camera. <br /><br /><input type="submit" value="Submit" name="submit" /></form></body></html>

That is the front page. I have some javascript going already to make some fields required.

Link to comment
Share on other sites

You don't need Javascript to redirect the user, you can use PHP's header() function and send a location header. The radio butons just need the URL of the page as their value, then you put that in the location header.

Link to comment
Share on other sites

or alternatively you could map the value to a page on the server side. one half dozen to the other, I suppose.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...