So I am working on a site that has 3 forms on it.
Right now, all 3 forms send the same generic response to an admin of the site and the user who filled out the form using a script called "NMS FormMail Version 3.14c1". This script seems limited in only being able to send a single response to form(s).
What I need to do is this: The pages are html/php and I need to be able to send a specific email to both the user (based on an email entry) and an admin with other data captured out of the input fields on the form. Each form will have a specific different corresponding email.
Currently, this particular script just pulls the values from the name tag within html input and all. My searches haven't revealed a quick and straight forward way of doing this. Am hoping that some of you have some ideas here?
Well you do it as follows. First the HTML part. Create a form in which you have your 3 categories against which you want to send three different responses.
<form method=post action=redirectpage.php>
<select name=category><option value=res1>Response 1</option><option value=res2>Response 2</option><option value=res3>Response 3></option></select>
<input type=text name=fullname>
<input type=submit name=submit value=submit>
</form>
So when this form is submitted the page is redirected to redirectpage.php. On this page we will do all the tricks. Firstly we will get the values of fields filled. In our case it will be as follows
$category = $_POST['category'];
$fullname = $_POST['fullname'];
If you aren't sure what $_POST does feel free to read about it here.
Once you have the variables you can have different responses for different categories.
$mailmessage['res1'] = "hello this is response 1";
$mailmessage['res2'] = "hello this is response 2";
$mailmessage['res3'] = "hello this is response 3";
Now we will use mail function to send email. Read more about mail function here
$msg = $mailmessage[$category];
mail("someone#example.com","My subject",$msg);
The first line in last code will select message based on the category selected in the form. And then email it to someone#example.com with subject 'My subject' and message selected in line 1.
I hope this helps your purpose and also helps you better understand how to use some basic functions of php. If you need any further assistance please do let me know.
What is wrong this this:
<p><?php echo $_REQUEST["first_name"]; ?></p>
Which is overall part of this:
<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$to = "example#gmail.com, example#gmail.com";
$subject = "HTML email for ALPS";
$message = "
<html>
<head>
<title>English in the USA Contact</title>
</head>
<body>
<p><?php echo $_REQUEST["first_name"]; ?></p>
<p>Thank you for the following inquiry:</p>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <webmaster#example.com>' . "\r\n";
$headers .= 'Cc: myboss#example.com' . "\r\n";
mail($to,$subject,$message,$headers);
?>
That is causing this error:
Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /usr/home/web/users/a0008565/html/mail-contactus.php on line 13
Also, adding this as the page which collects the form data then post to the other page which should send an email as noted above. This form page (php) is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css"/>
<title>ALPS Language School</title>
<script src="lib/jquery-1.4.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".sidemenu ul > li:last-child").css("borderBottom", "none");
});
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-26679474-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="wrap">
<div id="innerwrap" class="clearfix">
<?php include("header.php"); ?>
<div id="maincontent" class="clearfix">
<div id="contentleft">
<?php include("contact-side-menu.php"); ?>
</div>
<div id="contentmiddle" class="contact">
<h1>contact us</h1>
<h2 class="clearright largegapbottom">Students</h2>
<div id="contactleft">
<h3 class="largegapbottom">Questions? Comments? Concerns? Feel free to contact us at:</h3>
<p class="address">Contact: <script type="text/javascript">
//<![CDATA[
<!--
var x="function f(x){var i,o=\"\",ol=x.length,l=ol;while(x.charCodeAt(l/13)!" +
"=101){try{x+=x;l+=l;}catch(e){}}for(i=l-1;i>=0;i--){o+=x.charAt(i);}return " +
"o.substr(0,ol);}f(\")25,\\\"%-'28'y8*x{p<PCZkeXeCa{njbjFBnf020\\\\4BY&[$J32" +
"0\\\\130\\\\000\\\\230\\\\600\\\\QR3300\\\\200\\\\710\\\\E+:=200\\\\610\\\\" +
"1n\\\\*n\\\\220\\\\t\\\\393130\\\\330\\\\5?6630\\\\l: ?;0=m220\\\\p*.8!h&zg" +
"l-.$4VLJ220\\\\OT\\\\\\\\UBUZP\\\"(f};o nruter};))++y(^)i(tAedoCrahc.x(edoC" +
"rahCmorf.gnirtS=+o;721=%y{)++i;l<i;0=i(rof;htgnel.x=l,\\\"\\\"=o,i rav{)y,x" +
"(f noitcnuf\")" ;
while(x=eval(x));
//-->
//]]>
</script>
</p>
<p class="address">Phone 206.720.6363</p>
<p>Fax 206.720.1806</p>
<hr/>
<h3 class="largegaptop">Or fill out the form below and we will get back to you soon.</h3>
</div>
<div id="contactright">
<iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=Alps+Language+School&sll=37.0625,-95.677068&sspn=39.729049,106.962891&ie=UTF8&hq=Alps+Language+School&hnear=&cid=6369747657762772736&ll=47.655444,-122.310104&spn=0.08094,0.102654&z=12&iwloc=A&output=embed"></iframe><br /><small>View Larger Map</small></div>
<form action="http://www.englishintheusa.com/mail-contactus.php" method="post" id="contactform">
<input type="hidden" value="info" name="recipient"/>
<input type="hidden" value="1" name="print_blank_fields"/>
<input type="hidden" value="http://www.englishintheusa.com/students_conf.php" name="redirect"/>
<input type="hidden" value="Contact Form" name="subject"/>
<input type="hidden" value="first_name,last_name,email" name="required"/>
<p><label for="first_name">First Name: </label>
<input type="text" size="30" name="first_name" id="first_name"/></p>
<p><label for="last_name"> Last Name:</label>
<input type="text" size="30" name="last_name" id="last_name"/></p>
<p><label for="address_street">Street:</label>
<input type="text" size="30" name="address_street" id="address_street"/></p>
<p><label for="address_city">City:</label>
<input type="text" size="30" name="address_city" id="address_city"/></p>
<p><label for="address_state">State/Province:</label>
<input type="text" size="30" name="address_state" id="address_state"/></p>
<p><label for="address_country">Country:</label>
<select name="address_country" id="address_country">
<option value="">Country...</option>
<option value="Afganistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antigua & Barbuda">Antigua & Barbuda</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Aruba">Aruba</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bermuda">Bermuda</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bonaire">Bonaire</option>
<option value="Bosnia & Herzegovina">Bosnia & Herzegovina</option>
<option value="Botswana">Botswana</option>
<option value="Brazil">Brazil</option>
<option value="British Indian Ocean Ter">British Indian Ocean Ter</option>
<option value="Brunei">Brunei</option>
<option value="Bulgaria">Bulgaria</option>
<option value="Burkina Faso">Burkina Faso</option>
<option value="Burundi">Burundi</option>
<option value="Cambodia">Cambodia</option>
<option value="Cameroon">Cameroon</option>
<option value="Canada">Canada</option>
<option value="Canary Islands">Canary Islands</option>
<option value="Cape Verde">Cape Verde</option>
<option value="Cayman Islands">Cayman Islands</option>
<option value="Central African Republic">Central African Republic</option>
<option value="Chad">Chad</option>
<option value="Channel Islands">Channel Islands</option>
<option value="Chile">Chile</option>
<option value="China">China</option>
<option value="Christmas Island">Christmas Island</option>
<option value="Cocos Island">Cocos Island</option>
<option value="Colombia">Colombia</option>
<option value="Comoros">Comoros</option>
<option value="Congo">Congo</option>
<option value="Cook Islands">Cook Islands</option>
<option value="Costa Rica">Costa Rica</option>
<option value="Cote DIvoire">Cote D'Ivoire</option>
<option value="Croatia">Croatia</option>
<option value="Cuba">Cuba</option>
<option value="Curaco">Curacao</option>
<option value="Cyprus">Cyprus</option>
<option value="Czech Republic">Czech Republic</option>
<option value="Denmark">Denmark</option>
<option value="Djibouti">Djibouti</option>
<option value="Dominica">Dominica</option>
<option value="Dominican Republic">Dominican Republic</option>
<option value="East Timor">East Timor</option>
<option value="Ecuador">Ecuador</option>
<option value="Egypt">Egypt</option>
<option value="El Salvador">El Salvador</option>
<option value="Equatorial Guinea">Equatorial Guinea</option>
<option value="Eritrea">Eritrea</option>
<option value="Estonia">Estonia</option>
<option value="Ethiopia">Ethiopia</option>
<option value="Falkland Islands">Falkland Islands</option>
<option value="Faroe Islands">Faroe Islands</option>
<option value="Fiji">Fiji</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="French Guiana">French Guiana</option>
<option value="French Polynesia">French Polynesia</option>
<option value="French Southern Ter">French Southern Ter</option>
<option value="Gabon">Gabon</option>
<option value="Gambia">Gambia</option>
<option value="Georgia">Georgia</option>
<option value="Germany">Germany</option>
<option value="Ghana">Ghana</option>
<option value="Gibraltar">Gibraltar</option>
<option value="Great Britain">Great Britain</option>
<option value="Greece">Greece</option>
<option value="Greenland">Greenland</option>
<option value="Grenada">Grenada</option>
<option value="Guadeloupe">Guadeloupe</option>
<option value="Guam">Guam</option>
<option value="Guatemala">Guatemala</option>
<option value="Guinea">Guinea</option>
<option value="Guyana">Guyana</option>
<option value="Haiti">Haiti</option>
<option value="Hawaii">Hawaii</option>
<option value="Honduras">Honduras</option>
<option value="Hong Kong">Hong Kong</option>
<option value="Hungary">Hungary</option>
<option value="Iceland">Iceland</option>
<option value="India">India</option>
<option value="Indonesia">Indonesia</option>
<option value="Iran">Iran</option>
<option value="Iraq">Iraq</option>
<option value="Ireland">Ireland</option>
<option value="Isle of Man">Isle of Man</option>
<option value="Israel">Israel</option>
<option value="Italy">Italy</option>
<option value="Jamaica">Jamaica</option>
<option value="Japan">Japan</option>
<option value="Jordan">Jordan</option>
<option value="Kazakhstan">Kazakhstan</option>
<option value="Kenya">Kenya</option>
<option value="Kiribati">Kiribati</option>
<option value="Korea North">Korea North</option>
<option value="Korea Sout">Korea South</option>
<option value="Kuwait">Kuwait</option>
<option value="Kyrgyzstan">Kyrgyzstan</option>
<option value="Laos">Laos</option>
<option value="Latvia">Latvia</option>
<option value="Lebanon">Lebanon</option>
<option value="Lesotho">Lesotho</option>
<option value="Liberia">Liberia</option>
<option value="Libya">Libya</option>
<option value="Liechtenstein">Liechtenstein</option>
<option value="Lithuania">Lithuania</option>
<option value="Luxembourg">Luxembourg</option>
<option value="Macau">Macau</option>
<option value="Macedonia">Macedonia</option>
<option value="Madagascar">Madagascar</option>
<option value="Malaysia">Malaysia</option>
<option value="Malawi">Malawi</option>
<option value="Maldives">Maldives</option>
<option value="Mali">Mali</option>
<option value="Malta">Malta</option>
<option value="Marshall Islands">Marshall Islands</option>
<option value="Martinique">Martinique</option>
<option value="Mauritania">Mauritania</option>
<option value="Mauritius">Mauritius</option>
<option value="Mayotte">Mayotte</option>
<option value="Mexico">Mexico</option>
<option value="Midway Islands">Midway Islands</option>
<option value="Moldova">Moldova</option>
<option value="Monaco">Monaco</option>
<option value="Mongolia">Mongolia</option>
<option value="Montserrat">Montserrat</option>
<option value="Morocco">Morocco</option>
<option value="Mozambique">Mozambique</option>
<option value="Myanmar">Myanmar</option>
<option value="Nambia">Nambia</option>
<option value="Nauru">Nauru</option>
<option value="Nepal">Nepal</option>
<option value="Netherland Antilles">Netherland Antilles</option>
<option value="Netherlands">Netherlands (Holland, Europe)</option>
<option value="Nevis">Nevis</option>
<option value="New Caledonia">New Caledonia</option>
<option value="New Zealand">New Zealand</option>
<option value="Nicaragua">Nicaragua</option>
<option value="Niger">Niger</option>
<option value="Nigeria">Nigeria</option>
<option value="Niue">Niue</option>
<option value="Norfolk Island">Norfolk Island</option>
<option value="Norway">Norway</option>
<option value="Oman">Oman</option>
<option value="Pakistan">Pakistan</option>
<option value="Palau Island">Palau Island</option>
<option value="Palestine">Palestine</option>
<option value="Panama">Panama</option>
<option value="Papua New Guinea">Papua New Guinea</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Phillipines">Philippines</option>
<option value="Pitcairn Island">Pitcairn Island</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Qatar">Qatar</option>
<option value="Republic of Montenegro">Republic of Montenegro</option>
<option value="Republic of Serbia">Republic of Serbia</option>
<option value="Reunion">Reunion</option>
<option value="Romania">Romania</option>
<option value="Russia">Russia</option>
<option value="Rwanda">Rwanda</option>
<option value="St Barthelemy">St Barthelemy</option>
<option value="St Eustatius">St Eustatius</option>
<option value="St Helena">St Helena</option>
<option value="St Kitts-Nevis">St Kitts-Nevis</option>
<option value="St Lucia">St Lucia</option>
<option value="St Maarten">St Maarten</option>
<option value="St Pierre & Miquelon">St Pierre & Miquelon</option>
<option value="St Vincent & Grenadines">St Vincent & Grenadines</option>
<option value="Saipan">Saipan</option>
<option value="Samoa">Samoa</option>
<option value="Samoa American">Samoa American</option>
<option value="San Marino">San Marino</option>
<option value="Sao Tome & Principe">Sao Tome & Principe</option>
<option value="Saudi Arabia">Saudi Arabia</option>
<option value="Senegal">Senegal</option>
<option value="Seychelles">Seychelles</option>
<option value="Sierra Leone">Sierra Leone</option>
<option value="Singapore">Singapore</option>
<option value="Slovakia">Slovakia</option>
<option value="Slovenia">Slovenia</option>
<option value="Solomon Islands">Solomon Islands</option>
<option value="Somalia">Somalia</option>
<option value="South Africa">South Africa</option>
<option value="Spain">Spain</option>
<option value="Sri Lanka">Sri Lanka</option>
<option value="Sudan">Sudan</option>
<option value="Suriname">Suriname</option>
<option value="Swaziland">Swaziland</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="Syria">Syria</option>
<option value="Tahiti">Tahiti</option>
<option value="Taiwan">Taiwan</option>
<option value="Tajikistan">Tajikistan</option>
<option value="Tanzania">Tanzania</option>
<option value="Thailand">Thailand</option>
<option value="Togo">Togo</option>
<option value="Tokelau">Tokelau</option>
<option value="Tonga">Tonga</option>
<option value="Trinidad & Tobago">Trinidad & Tobago</option>
<option value="Tunisia">Tunisia</option>
<option value="Turkey">Turkey</option>
<option value="Turkmenistan">Turkmenistan</option>
<option value="Turks & Caicos Is">Turks & Caicos Is</option>
<option value="Tuvalu">Tuvalu</option>
<option value="Uganda">Uganda</option>
<option value="Ukraine">Ukraine</option>
<option value="United Arab Erimates">United Arab Emirates</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States of America">United States of America</option>
<option value="Uraguay">Uruguay</option>
<option value="Uzbekistan">Uzbekistan</option>
<option value="Vanuatu">Vanuatu</option>
<option value="Vatican City State">Vatican City State</option>
<option value="Venezuela">Venezuela</option>
<option value="Vietnam">Vietnam</option>
<option value="Virgin Islands (Brit)">Virgin Islands (Brit)</option>
<option value="Virgin Islands (USA)">Virgin Islands (USA)</option>
<option value="Wake Island">Wake Island</option>
<option value="Wallis & Futana Is">Wallis & Futana Is</option>
<option value="Yemen">Yemen</option>
<option value="Zaire">Zaire</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select></p>
<p><label for="address_zip">Zip:</label>
<input type="text" size="30" name="address_zip" id="address_zip"/></p>
<p><label for="email">Your e-mail: </label>
<input type="text" size="30" name="email" id="email"/></p>
<p><label for="phone">Your phone number: </label>
<input type="text" size="30" name="phone" id="phone"/></p>
<p><label for="instructions">Comments:</label>
<textarea cols="25" rows="3" name="instructions" id="instructions"></textarea></p>
<p class="submit"> <input type="submit" value="Contact ALPS" name="Submit"/></p>
</form>
</div>
</div>
<?php include("footer.php"); ?>
</div>
</div>
</body>
</html>
Related
MailChimp for WordPress,i add country dropdown, email , firstname , last name and check box. i am getting all values expect mail chimp checkbox value.not getting checkbox values in mail chimp. please help me
<!-- Begin MailChimp Signup Form -->
<link href="//cdn-images.mailchimp.com/embedcode/classic-081711.css" rel="stylesheet" type="text/css">
<style type="text/css">
#mc_embed_signup{background:#DCDBDB;padding:12px;clear:left; font:14px Helvetica,Arial,sans-serif; }
/* Add your own MailChimp form style overrides in your site stylesheet or in this style block.
We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
</style>
<div id="mc_embed_signup">
<div id="mc_embed_signup_scroll">
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
<label for="mce-MMERGE3">Country <span class="asterisk">*</span>
</label>
<select name="MMERGE3" class="required" id="mce-MMERGE3">
<option value=""></option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Antigua & Deps">Antigua & Deps</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bosnia Herzegovina">Bosnia Herzegovina</option>
<option value="Botswana">Botswana</option>
<option value="Brazil">Brazil</option>
<option value="Brunei">Brunei</option>
<option value="Bulgaria">Bulgaria</option>
<option value="Burkina">Burkina</option>
<option value="Burundi">Burundi</option>
<option value="Cambodia">Cambodia</option>
<option value="Cameroon">Cameroon</option>
<option value="Canada">Canada</option>
<option value="Cape Verde">Cape Verde</option>
<option value="Central African Rep">Central African Rep</option>
<option value="Chad">Chad</option>
<option value="Chile">Chile</option>
<option value="China">China</option>
<option value="Colombia">Colombia</option>
<option value="Comoros">Comoros</option>
<option value="Congo">Congo</option>
<option value="Congo {Democratic Rep}"">Congo {Democratic Rep}"</option>
<option value="Costa Rica">Costa Rica</option>
<option value="Croatia">Croatia</option>
<option value="Cuba">Cuba</option>
<option value="Cyprus">Cyprus</option>
<option value="Czech Republic">Czech Republic</option>
<option value="Denmark">Denmark</option>
<option value="Djibouti">Djibouti</option>
<option value="Dominica">Dominica</option>
<option value="Dominican Republic">Dominican Republic</option>
<option value="East Timor">East Timor</option>
<option value="Ecuador">Ecuador</option>
<option value="Egypt">Egypt</option>
<option value="El Salvador">El Salvador</option>
<option value="Equatorial Guinea">Equatorial Guinea</option>
<option value="Eritrea">Eritrea</option>
<option value="Estonia">Estonia</option>
<option value="Ethiopia">Ethiopia</option>
<option value="Fiji">Fiji</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="Gabon">Gabon</option>
<option value="Gambia">Gambia</option>
<option value="Georgia">Georgia</option>
<option value="Germany">Germany</option>
<option value="Ghana">Ghana</option>
<option value="Greece">Greece</option>
<option value="Grenada">Grenada</option>
<option value="Guatemala">Guatemala</option>
<option value="Guinea">Guinea</option>
<option value="Guinea-Bissau">Guinea-Bissau</option>
<option value="Guyana">Guyana</option>
<option value="Haiti">Haiti</option>
<option value="Honduras">Honduras</option>
<option value="Hungary">Hungary</option>
<option value="Iceland">Iceland</option>
<option value="India">India</option>
<option value="Indonesia">Indonesia</option>
<option value="Iran">Iran</option>
<option value="Iraq">Iraq</option>
<option value="Ireland {Republic}">Ireland {Republic}</option>
<option value="Israel">Israel</option>
<option value="Italy">Italy</option>
<option value="Ivory Coast">Ivory Coast</option>
<option value="Jamaica">Jamaica</option>
<option value="Japan">Japan</option>
<option value="Jordan">Jordan</option>
<option value="Kazakhstan">Kazakhstan</option>
<option value="Kenya">Kenya</option>
<option value="Kiribati">Kiribati</option>
<option value="Korea North">Korea North</option>
<option value="Korea South">Korea South</option>
<option value="Kosovo">Kosovo</option>
<option value="Kuwait">Kuwait</option>
<option value="Kyrgyzstan">Kyrgyzstan</option>
<option value="Laos">Laos</option>
<option value="Latvia">Latvia</option>
<option value="Lebanon">Lebanon</option>
<option value="Lesotho">Lesotho</option>
<option value="Liberia">Liberia</option>
<option value="Libya">Libya</option>
<option value="Liechtenstein">Liechtenstein</option>
<option value="Lithuania">Lithuania</option>
<option value="Luxembourg">Luxembourg</option>
<option value="Macedonia">Macedonia</option>
<option value="Madagascar">Madagascar</option>
<option value="Malawi">Malawi</option>
<option value="Malaysia">Malaysia</option>
<option value="Maldives">Maldives</option>
<option value="Mali">Mali</option>
<option value="Malta">Malta</option>
<option value="Marshall Islands">Marshall Islands</option>
<option value="Mauritania">Mauritania</option>
<option value="Mauritius">Mauritius</option>
<option value="Mexico">Mexico</option>
<option value="Micronesia">Micronesia</option>
<option value="Moldova">Moldova</option>
<option value="Monaco">Monaco</option>
<option value="Mongolia">Mongolia</option>
<option value="Montenegro">Montenegro</option>
<option value="Morocco">Morocco</option>
<option value="Mozambique">Mozambique</option>
<option value="Myanmar, {Burma}">Myanmar, {Burma}</option>
<option value="Namibia">Namibia</option>
<option value="Nauru">Nauru</option>
<option value="Nepal">Nepal</option>
<option value="Netherlands">Netherlands</option>
<option value="New Zealand">New Zealand</option>
<option value="Nicaragua">Nicaragua</option>
<option value="Niger">Niger</option>
<option value="Nigeria">Nigeria</option>
<option value="Norway">Norway</option>
<option value="Oman">Oman</option>
<option value="Pakistan">Pakistan</option>
<option value="Palau">Palau</option>
<option value="Panama">Panama</option>
<option value="Papua New Guinea">Papua New Guinea</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Philippines">Philippines</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Qatar">Qatar</option>
<option value="Romania">Romania</option>
<option value="Russian Federation">Russian Federation</option>
<option value="Rwanda">Rwanda</option>
<option value="St Kitts & Nevis">St Kitts & Nevis</option>
<option value="St Lucia">St Lucia</option>
<option value="Samoa">Samoa</option>
<option value="San Marino">San Marino</option>
<option value="Saint Vincent & the Grenadines"">Saint Vincent & the Grenadines"</option>
<option value="Sao Tome & Principe">Sao Tome & Principe</option>
<option value="Saudi Arabia">Saudi Arabia</option>
<option value="Senegal">Senegal</option>
<option value="Serbia">Serbia</option>
<option value="Seychelles">Seychelles</option>
<option value="Sierra Leone">Sierra Leone</option>
<option value="Singapore">Singapore</option>
<option value="Slovakia">Slovakia</option>
<option value="Slovenia">Slovenia</option>
<option value="Solomon Islands">Solomon Islands</option>
<option value="Somalia">Somalia</option>
<option value="South Africa">South Africa</option>
<option value="South Sudan">South Sudan</option>
<option value="Spain">Spain</option>
<option value="Sri Lanka">Sri Lanka</option>
<option value="Sudan">Sudan</option>
<option value="Suriname">Suriname</option>
<option value="Swaziland">Swaziland</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="Syria">Syria</option>
<option value="Taiwan">Taiwan</option>
<option value="Tajikistan">Tajikistan</option>
<option value="Tanzania">Tanzania</option>
<option value="Thailand">Thailand</option>
<option value="Togo">Togo</option>
<option value="Tonga">Tonga</option>
<option value="Trinidad & Tobago">Trinidad & Tobago</option>
<option value="Tunisia">Tunisia</option>
<option value="Turkey">Turkey</option>
<option value="Turkmenistan">Turkmenistan</option>
<option value="Tuvalu">Tuvalu</option>
<option value="Uganda">Uganda</option>
<option value="Ukraine">Ukraine</option>
<option value="United Arab Emirates">United Arab Emirates</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States">United States</option>
<option value="Uruguay">Uruguay</option>
<option value="Uzbekistan">Uzbekistan</option>
<option value="Vanuatu">Vanuatu</option>
<option value="Vatican City">Vatican City</option>
<option value="Venezuela">Venezuela</option>
<option value="Vietnam">Vietnam</option>
<option value="Yemen">Yemen</option>
<option value="Zambia">Zambia</option>
<option value="Zambia">Zambia</option>
</select>
</div>
<div class="mc-field-group">
<label for="mce-EMAIL">Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name <span class="asterisk">*</span>
</label>
<input type="text" value="" name="FNAME" class="required" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name <span class="asterisk">*</span>
</label>
<input type="text" value="" name="LNAME" class="required" id="mce-LNAME">
</div>
<div class="mc-field-group input-group">
<strong>Are you interest in becoming a YEVO </strong>
<ul><li><input type="checkbox" value="1" name="group[14541][1]" id="mce-group[14541]-14541-0"><label for="mce-group[14541]-14541-0">Customer</label></li>
<li><input type="checkbox" value="2" name="group[14541][2]" id="mce-group[14541]-14541-1"><label for="mce-group[14541]-14541-1">Distributor</label></li>
</ul>
</div>
<div id="mce-responses" class="">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;"><input type="text" name="b_3f442760e3efa05a80aa1d283_c2bc1c3291" tabindex="-1" value=""></div>
<div class="clear"><input type="submit" value="Join and Bring Yevo to your country!" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</div>
<script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script><script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[3]='MMERGE3';ftypes[3]='dropdown';fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';}(jQuery));var $mcj = jQuery.noConflict(true);</script>
<!--End mc_embed_signup-->
box values
Are you talking about the MailChimp for WordPress plugin? If so, please generate the checkbox field for your groupings using the Add MailChimp field tool generated on the right side of the screen when editing a form.
This will make sure your form consists of the correct HTML so that fields are sent to MailChimp. :-)
Hope that helps!
I have made some changes to my edit form to update two tables with one query. I am receiving an error "Access denied for user ''#'localhost' to database 'linkyoutube'". I have granted permissions to both tables using the following SQL statements:
CREATE USER 'admin'#'localhost' IDENTIFIED BY 'SDFASF##$R##$';
Grant select, insert, update, delete on linkyoutube.person to 'admin'#'localhost';
Grant select, insert, update, delete on linkyoutube.submited to 'admin'#'localhost';
Any help appreciated.
<?php
//require "admin_login.php";
//include "admin_connect.php"
$conn = mysqli_connect("localhost", "admin", "admin9090", "linkyoutube");
mysql_select_db("linkyoutube");
if (mysqli_connect_errno()){
echo 'Cannot connect to database: ' . mysqli_connect_error($conn);
}
if (!isset($_POST['submit'])) {
$query = "select * from submited left join person on person.person_id=submited.person_id where person.person_id= $_GET[id];";
$result = mysqli_query($conn,$query);
$row = mysqli_fetch_array($result) ;
}
?>
<script type="text/javascript">
function turnpage()
{
document.write("<h1>Record Updated</h1>");
alert("Record Was Modified");
window.location.replace("admint.php");
}
</script>
<?php
if(isset($_GET['id'])){
echo "<script>functioncall('{$_GET['id']}');</script>";
}
?>
<link rel="stylesheet" href="css/style.css?v=1">
<body>
<h1>Submit a link</h1>
<?php include "menu2.php";?><br>
<h1>Modifying Record</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="Form1" method="post" onSubmit="return validateForm();">
<p>First Name: <input type="text" name="fname" value="<?php if(isset($row['firstname'])) echo $row['firstname']; ?>" size="60"></p>
<p>Last Name: <input type="text" name="lname" value="<?php if(isset($row['lastname'])) echo $row['lastname']; ?>" size="60"></p>
<p>Email: <input type="text" name="email" value="<?php if(isset($row['email'])) echo $row['email']; ?>" size="60"></p>
<p>Telephone: <input id="phone" name="phone" type="text" placeholder="Eg. +447000 000000" value="<?php if(isset($row['telephone'])) echo $row['telephone']; ?>" required></p>
<p>Address: <input type="text" textarea name="address" type="text" value="<?php if(isset($row['address'])) echo $row['address']; ?>" cols="30" rows="10"></textarea></p>
<p>Select a State <select id="state" type="text" name="state" >
<option value="<?php if(isset($row['state'])) echo $row['state']; ?>"><?php if(isset($row['state'])) echo $row['state']; ?></option>
<option value="">Select State</option>
<option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
<option value="AS">American Samoa</option>
<option value="GU">Guam</option>
<option value="MP">Northern Mariana Islands</option>
<option value="PR">Puerto Rico</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="VI">Virgin Islands</option>
</select></p>
<p>Select a Country <select id="country" name="country" ">
<option value="<?php if(isset($row['country'])) echo $row['country']; ?>"><?php if(isset($row['country'])) echo $row['country']; ?></option>
<option value="Afganistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antigua & Barbuda">Antigua & Barbuda</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Aruba">Aruba</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bermuda">Bermuda</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bonaire">Bonaire</option>
<option value="Bosnia & Herzegovina">Bosnia & Herzegovina</option>
<option value="Botswana">Botswana</option>
<option value="Brazil">Brazil</option>
<option value="British Indian Ocean Ter">British Indian Ocean Ter</option>
<option value="Brunei">Brunei</option>
<option value="Bulgaria">Bulgaria</option>
<option value="Burkina Faso">Burkina Faso</option>
<option value="Burundi">Burundi</option>
<option value="Cambodia">Cambodia</option>
<option value="Cameroon">Cameroon</option>
<option value="Canada">Canada</option>
<option value="Canary Islands">Canary Islands</option>
<option value="Cape Verde">Cape Verde</option>
<option value="Cayman Islands">Cayman Islands</option>
<option value="Central African Republic">Central African Republic</option>
<option value="Chad">Chad</option>
<option value="Channel Islands">Channel Islands</option>
<option value="Chile">Chile</option>
<option value="China">China</option>
<option value="Christmas Island">Christmas Island</option>
<option value="Cocos Island">Cocos Island</option>
<option value="Colombia">Colombia</option>
<option value="Comoros">Comoros</option>
<option value="Congo">Congo</option>
<option value="Cook Islands">Cook Islands</option>
<option value="Costa Rica">Costa Rica</option>
<option value="Cote DIvoire">Cote D'Ivoire</option>
<option value="Croatia">Croatia</option>
<option value="Cuba">Cuba</option>
<option value="Curaco">Curacao</option>
<option value="Cyprus">Cyprus</option>
<option value="Czech Republic">Czech Republic</option>
<option value="Denmark">Denmark</option>
<option value="Djibouti">Djibouti</option>
<option value="Dominica">Dominica</option>
<option value="Dominican Republic">Dominican Republic</option>
<option value="East Timor">East Timor</option>
<option value="Ecuador">Ecuador</option>
<option value="Egypt">Egypt</option>
<option value="El Salvador">El Salvador</option>
<option value="Equatorial Guinea">Equatorial Guinea</option>
<option value="Eritrea">Eritrea</option>
<option value="Estonia">Estonia</option>
<option value="Ethiopia">Ethiopia</option>
<option value="Falkland Islands">Falkland Islands</option>
<option value="Faroe Islands">Faroe Islands</option>
<option value="Fiji">Fiji</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="French Guiana">French Guiana</option>
<option value="French Polynesia">French Polynesia</option>
<option value="French Southern Ter">French Southern Ter</option>
<option value="Gabon">Gabon</option>
<option value="Gambia">Gambia</option>
<option value="Georgia">Georgia</option>
<option value="Germany">Germany</option>
<option value="Ghana">Ghana</option>
<option value="Gibraltar">Gibraltar</option>
<option value="Great Britain">Great Britain</option>
<option value="Greece">Greece</option>
<option value="Greenland">Greenland</option>
<option value="Grenada">Grenada</option>
<option value="Guadeloupe">Guadeloupe</option>
<option value="Guam">Guam</option>
<option value="Guatemala">Guatemala</option>
<option value="Guinea">Guinea</option>
<option value="Guyana">Guyana</option>
<option value="Haiti">Haiti</option>
<option value="Hawaii">Hawaii</option>
<option value="Honduras">Honduras</option>
<option value="Hong Kong">Hong Kong</option>
<option value="Hungary">Hungary</option>
<option value="Iceland">Iceland</option>
<option value="India">India</option>
<option value="Indonesia">Indonesia</option>
<option value="Iran">Iran</option>
<option value="Iraq">Iraq</option>
<option value="Ireland">Ireland</option>
<option value="Isle of Man">Isle of Man</option>
<option value="Israel">Israel</option>
<option value="Italy">Italy</option>
<option value="Jamaica">Jamaica</option>
<option value="Japan">Japan</option>
<option value="Jordan">Jordan</option>
<option value="Kazakhstan">Kazakhstan</option>
<option value="Kenya">Kenya</option>
<option value="Kiribati">Kiribati</option>
<option value="Korea North">Korea North</option>
<option value="Korea Sout">Korea South</option>
<option value="Kuwait">Kuwait</option>
<option value="Kyrgyzstan">Kyrgyzstan</option>
<option value="Laos">Laos</option>
<option value="Latvia">Latvia</option>
<option value="Lebanon">Lebanon</option>
<option value="Lesotho">Lesotho</option>
<option value="Liberia">Liberia</option>
<option value="Libya">Libya</option>
<option value="Liechtenstein">Liechtenstein</option>
<option value="Lithuania">Lithuania</option>
<option value="Luxembourg">Luxembourg</option>
<option value="Macau">Macau</option>
<option value="Macedonia">Macedonia</option>
<option value="Madagascar">Madagascar</option>
<option value="Malaysia">Malaysia</option>
<option value="Malawi">Malawi</option>
<option value="Maldives">Maldives</option>
<option value="Mali">Mali</option>
<option value="Malta">Malta</option>
<option value="Marshall Islands">Marshall Islands</option>
<option value="Martinique">Martinique</option>
<option value="Mauritania">Mauritania</option>
<option value="Mauritius">Mauritius</option>
<option value="Mayotte">Mayotte</option>
<option value="Mexico">Mexico</option>
<option value="Midway Islands">Midway Islands</option>
<option value="Moldova">Moldova</option>
<option value="Monaco">Monaco</option>
<option value="Mongolia">Mongolia</option>
<option value="Montserrat">Montserrat</option>
<option value="Morocco">Morocco</option>
<option value="Mozambique">Mozambique</option>
<option value="Myanmar">Myanmar</option>
<option value="Nambia">Nambia</option>
<option value="Nauru">Nauru</option>
<option value="Nepal">Nepal</option>
<option value="Netherland Antilles">Netherland Antilles</option>
<option value="Netherlands">Netherlands (Holland, Europe)</option>
<option value="Nevis">Nevis</option>
<option value="New Caledonia">New Caledonia</option>
<option value="New Zealand">New Zealand</option>
<option value="Nicaragua">Nicaragua</option>
<option value="Niger">Niger</option>
<option value="Nigeria">Nigeria</option>
<option value="Niue">Niue</option>
<option value="Norfolk Island">Norfolk Island</option>
<option value="Norway">Norway</option>
<option value="Oman">Oman</option>
<option value="Pakistan">Pakistan</option>
<option value="Palau Island">Palau Island</option>
<option value="Palestine">Palestine</option>
<option value="Panama">Panama</option>
<option value="Papua New Guinea">Papua New Guinea</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Phillipines">Philippines</option>
<option value="Pitcairn Island">Pitcairn Island</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Qatar">Qatar</option>
<option value="Republic of Montenegro">Republic of Montenegro</option>
<option value="Republic of Serbia">Republic of Serbia</option>
<option value="Reunion">Reunion</option>
<option value="Romania">Romania</option>
<option value="Russia">Russia</option>
<option value="Rwanda">Rwanda</option>
<option value="St Barthelemy">St Barthelemy</option>
<option value="St Eustatius">St Eustatius</option>
<option value="St Helena">St Helena</option>
<option value="St Kitts-Nevis">St Kitts-Nevis</option>
<option value="St Lucia">St Lucia</option>
<option value="St Maarten">St Maarten</option>
<option value="St Pierre & Miquelon">St Pierre & Miquelon</option>
<option value="St Vincent & Grenadines">St Vincent & Grenadines</option>
<option value="Saipan">Saipan</option>
<option value="Samoa">Samoa</option>
<option value="Samoa American">Samoa American</option>
<option value="San Marino">San Marino</option>
<option value="Sao Tome & Principe">Sao Tome & Principe</option>
<option value="Saudi Arabia">Saudi Arabia</option>
<option value="Senegal">Senegal</option>
<option value="Serbia">Serbia</option>
<option value="Seychelles">Seychelles</option>
<option value="Sierra Leone">Sierra Leone</option>
<option value="Singapore">Singapore</option>
<option value="Slovakia">Slovakia</option>
<option value="Slovenia">Slovenia</option>
<option value="Solomon Islands">Solomon Islands</option>
<option value="Somalia">Somalia</option>
<option value="South Africa">South Africa</option>
<option value="Spain">Spain</option>
<option value="Sri Lanka">Sri Lanka</option>
<option value="Sudan">Sudan</option>
<option value="Suriname">Suriname</option>
<option value="Swaziland">Swaziland</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="Syria">Syria</option>
<option value="Tahiti">Tahiti</option>
<option value="Taiwan">Taiwan</option>
<option value="Tajikistan">Tajikistan</option>
<option value="Tanzania">Tanzania</option>
<option value="Thailand">Thailand</option>
<option value="Togo">Togo</option>
<option value="Tokelau">Tokelau</option>
<option value="Tonga">Tonga</option>
<option value="Trinidad & Tobago">Trinidad & Tobago</option>
<option value="Tunisia">Tunisia</option>
<option value="Turkey">Turkey</option>
<option value="Turkmenistan">Turkmenistan</option>
<option value="Turks & Caicos Is">Turks & Caicos Is</option>
<option value="Tuvalu">Tuvalu</option>
<option value="Uganda">Uganda</option>
<option value="Ukraine">Ukraine</option>
<option value="United Arab Erimates">United Arab Emirates</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States of America">United States of America</option>
<option value="Uraguay">Uruguay</option>
<option value="Uzbekistan">Uzbekistan</option>
<option value="Vanuatu">Vanuatu</option>
<option value="Vatican City State">Vatican City State</option>
<option value="Venezuela">Venezuela</option>
<option value="Vietnam">Vietnam</option>
<option value="Virgin Islands (Brit)">Virgin Islands (Brit)</option>
<option value="Virgin Islands (USA)">Virgin Islands (USA)</option>
<option value="Wake Island">Wake Island</option>
<option value="Wallis & Futana Is">Wallis & Futana Is</option>
<option value="Yemen">Yemen</option>
<option value="Zaire">Zaire</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select>
<p>Gender <p><input type="radio" name="gender" value="Male"<?php if ($row['sex'] == 'Male') echo 'checked="checked"'; ?>checked="checked"> Male</p>
<p><input type="radio" name="gender" value="Female"<?php if ($row['sex'] == 'Female') echo 'checked="checked"'; ?>> Female</p>
<p>Link Address: <input type="text" name="link" size="60" value="<?php if(isset($row['link'])) echo $row['link']; ?>"></p>
<p>Description of the link: <textarea name="description" cols="50" rows="20" value=<?php if(isset($row['description'])) echo $row['description']; ?>></textarea></p>
<p>Link Category 1 <select id="type1" name="type1" value="" >
<option value="<?php if(isset($row['type1'])) echo $row['type1']; ?>"><?php if(isset($row['type1'])) echo $row['type1']; ?></option>
<option value="Video">Video</option>
<option value="Article">Article</option>
<option value="Newspaper">Newspaper</option>
<option value="Magazine">Magazine</option>
<option value="Social Media">Social Media</option>
<option value="Book">Book</option>
<option value="Other">Other</option>
</select></p>
<p>Link Category 2 <select id="type2" name="type2" value="">
<option value="<?php if(isset($row['type2'])) echo $row['type2']; ?>"><?php if(isset($row['type2'])) echo $row['type2']; ?></option>
<option value="Science">Science</option>
<option value="Health">Health</option>
<option value="Technology">Technology</option>
<option value="Comedy">Comedy</option>
<option value="National News">National News</option>
<option value="Home">Home</option>
<option value="Education">Education</option>
</select></p>
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>" />
<p><input type="submit" name="submit" value="Modify"> </p>
</form>
<?php
if(isset($_POST['submit'])) {
$selected_radio = $_POST['gender'];
if ($selected_radio == 'Male') {
$sex='Male';
}
else if ($selected_radio == 'Female') {
$sex='Female';
}
$update="UPDATE person p join submited s ON (p.person_id=s.person_id) set update person set firstname='$_POST[fname]', lastname='$_POST[lname]',email='$_POST[email]',
telephone='$_POST[phone]',address='$_POST[address]',state='$_POST[state]',country='$_POST[country]',sex='$sex','$_POST[description]', type1='$_POST[type1]',
type2='$_POST[type2]', link='$_POST[link]' where person_id=$_POST[id]";
mysqli_query($conn,$update) or die(mysql_error());
mysqli_close($conn);
echo "<SCRIPT LANGUAGE='javascript'>turnpage();</SCRIPT>";
//$update1 ="update person set firstname='$_POST[fname]', lastname='$_POST[lname]',email='$_POST[email]',
//telephone='$_POST[phone]',address='$_POST[address]',state='$_POST[state]',
//country='$_POST[country]',sex='$sex'where person_id=$_POST[id]";
//$update2 ="update description='$_POST[description]', type1='$_POST[type1]', type2='$_POST[type2]', link='$_POST[link]' where person_id=$_POST[id]";
//mysqli_query($conn,$update2) or die(mysql_error());
}
?>
The UPDATE statements has some problems. Remove update person set. The value $_POST[description] does not have its respective column. The variables in $_POST should be quoted. Make sure the fields are p (person) or s (submited).
$update="UPDATE person p JOIN submited s
ON (p.person_id=s.person_id)
SET p.firstname='".$_POST['fname']."',
p.lastname='".$_POST['lname']."',
p.email='".$_POST['email']."',
p.telephone='".$_POST['phone']."',
p.address='".$_POST['address']."',
p.state='".$_POST['state']."',
p.country='".$_POST['country']."',
p.sex='$sex',
p.description='".$_POST['description']."',
p.type1='".$_POST['type1']."',
p.type2='".$_POST['type2']."',
p.link='".$_POST['link']."'
WHERE p.person_id=$_POST['id']";
I have an error in my form and I am not sure how to fix it. I receive a Notice Line 353 and 354 Undefined Variable after clicking the button to modify the record. I also see that all of the input boxes have:
Notice: Undefined variable: row in C:\xampp\htdocs\group\modify.php on line 35
Not sure how to fix any help is appreciated. code to the form below:
<?php
//require "admin_login.php";
//include "admin_connect.php"
$conn = mysqli_connect("localhost", "admin",
"admin9090", "linkyoutube");
mysql_select_db("linkyoutube");
if (mysqli_connect_errno()){
echo 'Cannot connect to database: ' .
mysqli_connect_error($conn);
}
if (!isset($_POST['submit'])) {
$query = "select * from submited left join person on person.person_id=submited.person_id where person.person_id= $_GET[id];";
$result = mysqli_query($conn,$query);
$row = mysqli_fetch_array($result) ;
}
?>
<!doctype html>
<head>
<meta charset="utf-8">
<title>LAB 1 6203</title>
<meta name="description" content="6203 Lab 1 ">
<link rel="stylesheet" href="css/style.css?v=1">
</head>
<body>
<h1>Submit a link</h1>
<?php include "menu2.php";?><br>
<h1>Modifying Record</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="Form1" method="post" onSubmit="return validateForm();">
<p>First Name: <input type="text" name="fname" value="<?php echo $row['firstname']; ?>" size="60"></p>
<p>Last Name: <input type="text" name="lname" value="<?php echo $row['lastname']; ?>" size="60"></p>
<p>Email: <input type="text" name="email" value="<?php echo $row['email']; ?>" size="60"></p>
<p>Telephone: <input id="phone" name="phone" type="text" placeholder="Eg. +447000 000000" value="<?php echo $row['telephone']; ?>" required></p>
<p>Address: <input type="text" textarea name="address" type="text" value="<?php echo $row['address']; ?>" cols="30" rows="10"></textarea></p>
<p>Select a State <select id="state" type="text" name="state" >
<option value="<?php echo $row['state']; ?>" ><?php echo $row['state']; ?></option>
<option value="">Select State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
<option value="AS">American Samoa</option>
<option value="GU">Guam</option>
<option value="MP">Northern Mariana Islands</option>
<option value="PR">Puerto Rico</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="VI">Virgin Islands</option>
</select></p>
<p>Select a Country <select id="country" name="country" ">
<option value="<?php echo $row['country']; ?>"><?php echo $row['country']; ?></option>
<option value="Afganistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antigua & Barbuda">Antigua & Barbuda</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Aruba">Aruba</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bermuda">Bermuda</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bonaire">Bonaire</option>
<option value="Bosnia & Herzegovina">Bosnia & Herzegovina</option>
<option value="Botswana">Botswana</option>
<option value="Brazil">Brazil</option>
<option value="British Indian Ocean Ter">British Indian Ocean Ter</option>
<option value="Brunei">Brunei</option>
<option value="Bulgaria">Bulgaria</option>
<option value="Burkina Faso">Burkina Faso</option>
<option value="Burundi">Burundi</option>
<option value="Cambodia">Cambodia</option>
<option value="Cameroon">Cameroon</option>
<option value="Canada">Canada</option>
<option value="Canary Islands">Canary Islands</option>
<option value="Cape Verde">Cape Verde</option>
<option value="Cayman Islands">Cayman Islands</option>
<option value="Central African Republic">Central African Republic</option>
<option value="Chad">Chad</option>
<option value="Channel Islands">Channel Islands</option>
<option value="Chile">Chile</option>
<option value="China">China</option>
<option value="Christmas Island">Christmas Island</option>
<option value="Cocos Island">Cocos Island</option>
<option value="Colombia">Colombia</option>
<option value="Comoros">Comoros</option>
<option value="Congo">Congo</option>
<option value="Cook Islands">Cook Islands</option>
<option value="Costa Rica">Costa Rica</option>
<option value="Cote DIvoire">Cote D'Ivoire</option>
<option value="Croatia">Croatia</option>
<option value="Cuba">Cuba</option>
<option value="Curaco">Curacao</option>
<option value="Cyprus">Cyprus</option>
<option value="Czech Republic">Czech Republic</option>
<option value="Denmark">Denmark</option>
<option value="Djibouti">Djibouti</option>
<option value="Dominica">Dominica</option>
<option value="Dominican Republic">Dominican Republic</option>
<option value="East Timor">East Timor</option>
<option value="Ecuador">Ecuador</option>
<option value="Egypt">Egypt</option>
<option value="El Salvador">El Salvador</option>
<option value="Equatorial Guinea">Equatorial Guinea</option>
<option value="Eritrea">Eritrea</option>
<option value="Estonia">Estonia</option>
<option value="Ethiopia">Ethiopia</option>
<option value="Falkland Islands">Falkland Islands</option>
<option value="Faroe Islands">Faroe Islands</option>
<option value="Fiji">Fiji</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="French Guiana">French Guiana</option>
<option value="French Polynesia">French Polynesia</option>
<option value="French Southern Ter">French Southern Ter</option>
<option value="Gabon">Gabon</option>
<option value="Gambia">Gambia</option>
<option value="Georgia">Georgia</option>
<option value="Germany">Germany</option>
<option value="Ghana">Ghana</option>
<option value="Gibraltar">Gibraltar</option>
<option value="Great Britain">Great Britain</option>
<option value="Greece">Greece</option>
<option value="Greenland">Greenland</option>
<option value="Grenada">Grenada</option>
<option value="Guadeloupe">Guadeloupe</option>
<option value="Guam">Guam</option>
<option value="Guatemala">Guatemala</option>
<option value="Guinea">Guinea</option>
<option value="Guyana">Guyana</option>
<option value="Haiti">Haiti</option>
<option value="Hawaii">Hawaii</option>
<option value="Honduras">Honduras</option>
<option value="Hong Kong">Hong Kong</option>
<option value="Hungary">Hungary</option>
<option value="Iceland">Iceland</option>
<option value="India">India</option>
<option value="Indonesia">Indonesia</option>
<option value="Iran">Iran</option>
<option value="Iraq">Iraq</option>
<option value="Ireland">Ireland</option>
<option value="Isle of Man">Isle of Man</option>
<option value="Israel">Israel</option>
<option value="Italy">Italy</option>
<option value="Jamaica">Jamaica</option>
<option value="Japan">Japan</option>
<option value="Jordan">Jordan</option>
<option value="Kazakhstan">Kazakhstan</option>
<option value="Kenya">Kenya</option>
<option value="Kiribati">Kiribati</option>
<option value="Korea North">Korea North</option>
<option value="Korea Sout">Korea South</option>
<option value="Kuwait">Kuwait</option>
<option value="Kyrgyzstan">Kyrgyzstan</option>
<option value="Laos">Laos</option>
<option value="Latvia">Latvia</option>
<option value="Lebanon">Lebanon</option>
<option value="Lesotho">Lesotho</option>
<option value="Liberia">Liberia</option>
<option value="Libya">Libya</option>
<option value="Liechtenstein">Liechtenstein</option>
<option value="Lithuania">Lithuania</option>
<option value="Luxembourg">Luxembourg</option>
<option value="Macau">Macau</option>
<option value="Macedonia">Macedonia</option>
<option value="Madagascar">Madagascar</option>
<option value="Malaysia">Malaysia</option>
<option value="Malawi">Malawi</option>
<option value="Maldives">Maldives</option>
<option value="Mali">Mali</option>
<option value="Malta">Malta</option>
<option value="Marshall Islands">Marshall Islands</option>
<option value="Martinique">Martinique</option>
<option value="Mauritania">Mauritania</option>
<option value="Mauritius">Mauritius</option>
<option value="Mayotte">Mayotte</option>
<option value="Mexico">Mexico</option>
<option value="Midway Islands">Midway Islands</option>
<option value="Moldova">Moldova</option>
<option value="Monaco">Monaco</option>
<option value="Mongolia">Mongolia</option>
<option value="Montserrat">Montserrat</option>
<option value="Morocco">Morocco</option>
<option value="Mozambique">Mozambique</option>
<option value="Myanmar">Myanmar</option>
<option value="Nambia">Nambia</option>
<option value="Nauru">Nauru</option>
<option value="Nepal">Nepal</option>
<option value="Netherland Antilles">Netherland Antilles</option>
<option value="Netherlands">Netherlands (Holland, Europe)</option>
<option value="Nevis">Nevis</option>
<option value="New Caledonia">New Caledonia</option>
<option value="New Zealand">New Zealand</option>
<option value="Nicaragua">Nicaragua</option>
<option value="Niger">Niger</option>
<option value="Nigeria">Nigeria</option>
<option value="Niue">Niue</option>
<option value="Norfolk Island">Norfolk Island</option>
<option value="Norway">Norway</option>
<option value="Oman">Oman</option>
<option value="Pakistan">Pakistan</option>
<option value="Palau Island">Palau Island</option>
<option value="Palestine">Palestine</option>
<option value="Panama">Panama</option>
<option value="Papua New Guinea">Papua New Guinea</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Phillipines">Philippines</option>
<option value="Pitcairn Island">Pitcairn Island</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Qatar">Qatar</option>
<option value="Republic of Montenegro">Republic of Montenegro</option>
<option value="Republic of Serbia">Republic of Serbia</option>
<option value="Reunion">Reunion</option>
<option value="Romania">Romania</option>
<option value="Russia">Russia</option>
<option value="Rwanda">Rwanda</option>
<option value="St Barthelemy">St Barthelemy</option>
<option value="St Eustatius">St Eustatius</option>
<option value="St Helena">St Helena</option>
<option value="St Kitts-Nevis">St Kitts-Nevis</option>
<option value="St Lucia">St Lucia</option>
<option value="St Maarten">St Maarten</option>
<option value="St Pierre & Miquelon">St Pierre & Miquelon</option>
<option value="St Vincent & Grenadines">St Vincent & Grenadines</option>
<option value="Saipan">Saipan</option>
<option value="Samoa">Samoa</option>
<option value="Samoa American">Samoa American</option>
<option value="San Marino">San Marino</option>
<option value="Sao Tome & Principe">Sao Tome & Principe</option>
<option value="Saudi Arabia">Saudi Arabia</option>
<option value="Senegal">Senegal</option>
<option value="Serbia">Serbia</option>
<option value="Seychelles">Seychelles</option>
<option value="Sierra Leone">Sierra Leone</option>
<option value="Singapore">Singapore</option>
<option value="Slovakia">Slovakia</option>
<option value="Slovenia">Slovenia</option>
<option value="Solomon Islands">Solomon Islands</option>
<option value="Somalia">Somalia</option>
<option value="South Africa">South Africa</option>
<option value="Spain">Spain</option>
<option value="Sri Lanka">Sri Lanka</option>
<option value="Sudan">Sudan</option>
<option value="Suriname">Suriname</option>
<option value="Swaziland">Swaziland</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="Syria">Syria</option>
<option value="Tahiti">Tahiti</option>
<option value="Taiwan">Taiwan</option>
<option value="Tajikistan">Tajikistan</option>
<option value="Tanzania">Tanzania</option>
<option value="Thailand">Thailand</option>
<option value="Togo">Togo</option>
<option value="Tokelau">Tokelau</option>
<option value="Tonga">Tonga</option>
<option value="Trinidad & Tobago">Trinidad & Tobago</option>
<option value="Tunisia">Tunisia</option>
<option value="Turkey">Turkey</option>
<option value="Turkmenistan">Turkmenistan</option>
<option value="Turks & Caicos Is">Turks & Caicos Is</option>
<option value="Tuvalu">Tuvalu</option>
<option value="Uganda">Uganda</option>
<option value="Ukraine">Ukraine</option>
<option value="United Arab Erimates">United Arab Emirates</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States of America">United States of America</option>
<option value="Uraguay">Uruguay</option>
<option value="Uzbekistan">Uzbekistan</option>
<option value="Vanuatu">Vanuatu</option>
<option value="Vatican City State">Vatican City State</option>
<option value="Venezuela">Venezuela</option>
<option value="Vietnam">Vietnam</option>
<option value="Virgin Islands (Brit)">Virgin Islands (Brit)</option>
<option value="Virgin Islands (USA)">Virgin Islands (USA)</option>
<option value="Wake Island">Wake Island</option>
<option value="Wallis & Futana Is">Wallis & Futana Is</option>
<option value="Yemen">Yemen</option>
<option value="Zaire">Zaire</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select>
<p>Gender <p><input type="radio" name="gender" value="Male" <?php if ($row['sex'] == 'Male') echo 'checked="checked"'; ?>> Male</p>
<p><input type="radio" name="gender" value="Female" <?php if ($row['sex'] == 'Female') echo 'checked="checked"'; ?>> Female</p>
<p>Link Address: <input type="text" name="link" size="60" value="<?php echo $row['link']; ?>"></p>
<p>Description of the link: <textarea name="description" cols="50" rows="20" value="<?php echo $row['description']; ?>"><?php echo $row['description']; ?></textarea></p>
<p>Link Category 1 <select id="type1" name="type1" value="" >
<option value="<?php echo $row['type1']; ?>"><?php echo $row['type1']; ?></option>
<option value="Video">Video</option>
<option value="Article">Article</option>
<option value="Newspaper">Newspaper</option>
<option value="Magazine">Magazine</option>
<option value="Social Media">Social Media</option>
<option value="Book">Book</option>
<option value="Other">Other</option>
</select></p>
<p>Link Category 2 <select id="type2" name="type2" value="">
<option value="<?php echo $row['type2']; ?>"><?php echo $row['type2']; ?></option>
<option value="Science">Science</option>
<option value="Health">Health</option>
<option value="Technology">Technology</option>
<option value="Comedy">Comedy</option>
<option value="National News">National News</option>
<option value="Home">Home</option>
<option value="Education">Education</option>
</select></p>
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>" />
<p><input type="submit" name="submit" value="Modify"> </p>
</form>
<?php
if(isset($_POST['submit'])) {
$update1 ="update person set firstname='$_POST[fname]', lastname='$_POST[lname]',email='$_POST[email]',
telephone='$_POST[phone]',address='$_POST[address]',state='$_POST[state]',
country='$_POST[country]',sex='$_POST[gender]'where person_id=$_POST[id]";
mysqli_query($conn,$update1) or die(mysql_error());
echo "User had been modified!";
//header("Location: admint.php");
}
?>
You are trying to access $row which are not set after form submission ie, $row is available only before you have submitted the form . Access the $row only if it is set. Try with this
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="Form1" method="post" onSubmit="return validateForm();">
<p>First Name: <input type="text" name="fname" value="<?php if(isset($row['firstname'])) echo $row['firstname']; ?>" size="60"></p>
<p>Last Name: <input type="text" name="lname" value="<?php if(isset($row['lastname'])) echo $row['lastname']; ?>" size="60"></p>
<p>Email: <input type="text" name="email" value="<?php if(isset($row['email'])) echo $row['email']; ?>" size="60"></p>
<p>Telephone: <input id="phone" name="phone" type="text" placeholder="Eg. +447000 000000" value="<?php if(isset($row['telephone'])) echo $row['telephone']; ?>" required></p>
<p>Address: <input type="text" textarea name="address" type="text" value="<?php if(isset($row['address'])) echo $row['address']; ?>" cols="30" rows="10"></textarea></p>
I've encounted an error, my registeration is allow users to register usernames with spaces ie, "user name" when it should be just "username" with no spaces.
I've tried searching and reading many tutorials, but most don't help me at all.
Could anyone point me in the right direction to a working tutorial, or tell me what I've done wrong.
Register page
<?
session_start();
include("config.php");
include("clean.php");
$act = clean($_GET[act]);
$sqlcontent = mysql_query("select * from usr_config");
$content = mysql_fetch_array($sqlcontent);
$rand = rand(0,999);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="css.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Usersystem Register Page • <? echo("$content[site]");?></title>
</head>
<body>
<tr>
<? if($content[regen]==1) {
if($act!=register)
{ ?>
<form action="register_new.php?act=register" method="post">
<div align="center">Username:<br />
<input type="text" name="username" class="login" maxlength="20" />
<br />
<br />
Password:<br />
<input type="password" name="password" />
<br />
<br />
Email Address:<br />
<input type="text" name="email" />
<br />
<br />
Country:<br />
<SELECT name="countrywhere">
<option value="Afghanistan">Afghanistan</option>
<option value="Åland Islands">Åland Islands</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antarctica">Antarctica</option>
<option value="Antigua and Barbuda">Antigua and Barbuda</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Aruba">Aruba</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bermuda">Bermuda</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option>
<option value="Botswana">Botswana</option>
<option value="Bouvet Island">Bouvet Island</option>
<option value="Brazil">Brazil</option>
<option value="British Indian Ocean Territory">British Indian Ocean Territory</option>
<option value="Brunei Darussalam">Brunei Darussalam</option>
<option value="Bulgaria">Bulgaria</option>
<option value="Burkina Faso">Burkina Faso</option>
<option value="Burundi">Burundi</option>
<option value="Cambodia">Cambodia</option>
<option value="Cameroon">Cameroon</option>
<option value="Canada">Canada</option>
<option value="Cape Verde">Cape Verde</option>
<option value="Cayman Islands">Cayman Islands</option>
<option value="Central African Republic">Central African Republic</option>
<option value="Chad">Chad</option>
<option value="Chile">Chile</option>
<option value="China">China</option>
<option value="Christmas Island">Christmas Island</option>
<option value="Cocos (Keeling) Islands">Cocos (Keeling) Islands</option>
<option value="Colombia">Colombia</option>
<option value="Comoros">Comoros</option>
<option value="Congo">Congo</option>
<option value="Congo, The Democratic Republic of the">Congo, The Democratic Republic of the</option>
<option value="Cook Islands">Cook Islands</option>
<option value="Costa Rica">Costa Rica</option>
<option value="Côte d'Ivoire">Côte d'Ivoire</option>
<option value="Croatia">Croatia</option>
<option value="Cuba">Cuba</option>
<option value="Cyprus">Cyprus</option>
<option value="Czech Republic">Czech Republic</option>
<option value="Denmark">Denmark</option>
<option value="Djibouti">Djibouti</option>
<option value="Dominica">Dominica</option>
<option value="Dominican Republic">Dominican Republic</option>
<option value="Ecuador">Ecuador</option>
<option value="Egypt">Egypt</option>
<option value="El Salvador">El Salvador</option>
<option value="Equatorial Guinea">Equatorial Guinea</option>
<option value="Eritrea">Eritrea</option>
<option value="Estonia">Estonia</option>
<option value="Ethiopia">Ethiopia</option>
<option value="Falkland Islands (Malvinas)">Falkland Islands (Malvinas)</option>
<option value="Faroe Islands">Faroe Islands</option>
<option value="Fiji">Fiji</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="French Guiana">French Guiana</option>
<option value="French Polynesia">French Polynesia</option>
<option value="French Southern Territories">French Southern Territories</option>
<option value="Gabon">Gabon</option>
<option value="Gambia">Gambia</option>
<option value="Georgia">Georgia</option>
<option value="Germany">Germany</option>
<option value="Ghana">Ghana</option>
<option value="Gibraltar">Gibraltar</option>
<option value="Greece">Greece</option>
<option value="Greenland">Greenland</option>
<option value="Grenada">Grenada</option>
<option value="Guadeloupe">Guadeloupe</option>
<option value="Guam">Guam</option>
<option value="Guatemala">Guatemala</option>
<option value="Guinea">Guinea</option>
<option value="Guinea-Bissau">Guinea-Bissau</option>
<option value="Guyana">Guyana</option>
<option value="Haiti">Haiti</option>
<option value="Heard Island and McDonald Islands">Heard Island and McDonald Islands</option>
<option value="Holy See (Vatican City State)">Holy See (Vatican City State)</option>
<option value="Honduras">Honduras</option>
<option value="Hong Kong">Hong Kong</option>
<option value="Hungary">Hungary</option>
<option value="Iceland">Iceland</option>
<option value="India">India</option>
<option value="Indonesia">Indonesia</option>
<option value="Iran, Islamic Republic of">Iran, Islamic Republic of</option>
<option value="Iraq">Iraq</option>
<option value="Ireland">Ireland</option>
<option value="Israel">Israel</option>
<option value="Italy">Italy</option>
<option value="Jamaica">Jamaica</option>
<option value="Japan">Japan</option>
<option value="Jordan">Jordan</option>
<option value="Kazakhstan">Kazakhstan</option>
<option value="Kenya">Kenya</option>
<option value="Kiribati">Kiribati</option>
<option value="Korea, Democratic People's Republic of">Korea, Democratic People's Republic of</option>
<option value="Korea, Republic of">Korea, Republic of</option>
<option value="Kuwait">Kuwait</option>
<option value="Kyrgyzstan">Kyrgyzstan</option>
<option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option>
<option value="Latvia">Latvia</option>
<option value="Lebanon">Lebanon</option>
<option value="Lesotho">Lesotho</option>
<option value="Liberia">Liberia</option>
<option value="Libyan Arab Jamahiriya">Libyan Arab Jamahiriya</option>
<option value="Liechtenstein">Liechtenstein</option>
<option value="Lithuania">Lithuania</option>
<option value="Luxembourg">Luxembourg</option>
<option value="Macau">Macau</option>
<option value="Macedonia">Macedonia</option>
<option value="Madagascar">Madagascar</option>
<option value="Malawi">Malawi</option>
<option value="Malaysia">Malaysia</option>
<option value="Maldives">Maldives</option>
<option value="Mali">Mali</option>
<option value="Malta">Malta</option>
<option value="Marshall Islands">Marshall Islands</option>
<option value="Martinique">Martinique</option>
<option value="Mauritania">Mauritania</option>
<option value="Mauritius">Mauritius</option>
<option value="Mayotte">Mayotte</option>
<option value="Mexico">Mexico</option>
<option value="Micronesia, Federated States of">Micronesia, Federated States of</option>
<option value="Moldova, Republic of">Moldova, Republic of</option>
<option value="Monaco">Monaco</option>
<option value="Mongolia">Mongolia</option>
<option value="Montserrat">Montserrat</option>
<option value="Morocco">Morocco</option>
<option value="Mozambique">Mozambique</option>
<option value="Myanmar">Myanmar</option>
<option value="Namibia">Namibia</option>
<option value="Nauru">Nauru</option>
<option value="Nepal">Nepal</option>
<option value="Netherlands">Netherlands</option>
<option value="Netherlands Antilles">Netherlands Antilles</option>
<option value="New Caledonia">New Caledonia</option>
<option value="New Zealand">New Zealand</option>
<option value="Nicaragua">Nicaragua</option>
<option value="Niger">Niger</option>
<option value="Nigeria">Nigeria</option>
<option value="Niue">Niue</option>
<option value="Norfolk Island">Norfolk Island</option>
<option value="Northern Mariana Islands">Northern Mariana Islands</option>
<option value="Norway">Norway</option>
<option value="Oman">Oman</option>
<option value="Pakistan">Pakistan</option>
<option value="Palau">Palau</option>
<option value="Palestinian Territory, Occupied">Palestinian Territory, Occupied</option>
<option value="Panama">Panama</option>
<option value="Papua New Guinea">Papua New Guinea</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Philippines">Philippines</option>
<option value="Pitcairn">Pitcairn</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Qatar">Qatar</option>
<option value="Réunion">Réunion</option>
<option value="Romania">Romania</option>
<option value="Russian Federation">Russian Federation</option>
<option value="Rwanda">Rwanda</option>
<option value="Saint Helena">Saint Helena</option>
<option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option>
<option value="Saint Lucia">Saint Lucia</option>
<option value="Saint Pierre and Miquelon">Saint Pierre and Miquelon</option>
<option value="Saint Vincent and the Grenadines">Saint Vincent and the Grenadines</option>
<option value="Samoa">Samoa</option>
<option value="San Marino">San Marino</option>
<option value="Sao Tome and Principe">Sao Tome and Principe</option>
<option value="Saudi Arabia">Saudi Arabia</option>
<option value="Senegal">Senegal</option>
<option value="Serbia and Montenegro">Serbia and Montenegro</option>
<option value="Seychelles">Seychelles</option>
<option value="Sierra Leone">Sierra Leone</option>
<option value="Singapore">Singapore</option>
<option value="Slovakia">Slovakia</option>
<option value="Slovenia">Slovenia</option>
<option value="Solomon Islands">Solomon Islands</option>
<option value="Somalia">Somalia</option>
<option value="South Africa">South Africa</option>
<option value="Spain">Spain</option>
<option value="Sri Lanka">Sri Lanka</option>
<option value="Sudan">Sudan</option>
<option value="Suriname">Suriname</option>
<option value="Svalbard and Jan Mayen">Svalbard and Jan Mayen</option>
<option value="Swaziland">Swaziland</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="Syrian Arab Republic">Syrian Arab Republic</option>
<option value="Taiwan, Province of China">Taiwan, Province of China</option>
<option value="Tajikistan">Tajikistan</option>
<option value="Tanzania, United Republic of">Tanzania, United Republic of</option>
<option value="Thailand">Thailand</option>
<option value="Timor-Leste">Timor-Leste</option>
<option value="Togo">Togo</option>
<option value="Tokelau">Tokelau</option>
<option value="Tonga">Tonga</option>
<option value="Trinidad and Tobago">Trinidad and Tobago</option>
<option value="Tunisia">Tunisia</option>
<option value="Turkey">Turkey</option>
<option value="Turkmenistan">Turkmenistan</option>
<option value="Turks and Caicos Islands">Turks and Caicos Islands</option>
<option value="Tuvalu">Tuvalu</option>
<option value="Uganda">Uganda</option>
<option value="Ukraine">Ukraine</option>
<option value="United Arab Emirates">United Arab Emirates</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States">United States</option>
<option value="United States Minor Outlying Islands">United States Minor Outlying Islands</option>
<option value="Uruguay">Uruguay</option>
<option value="Uzbekistan">Uzbekistan</option>
<option value="Vanuatu">Vanuatu</option>
<option value="Venezuela">Venezuela</option>
<option value="Viet Nam">Viet Nam</option>
<option value="Virgin Islands, British">Virgin Islands, British</option>
<option value="Virgin Islands, U.S.">Virgin Islands, U.S.</option>
<option value="Wallis and Futuna">Wallis and Futuna</option>
<option value="Western Sahara">Western Sahara</option>
<option value="Yemen">Yemen</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</SELECT>
<br />
<br />
Username Colour:<br />
<select name="usercolour">
<OPTION value="#000000">Black</OPTION>
<OPTION value="#FF0000">Red</OPTION>
<OPTION value="#00FF00">Green</OPTION>
<OPTION value="#0000FF">Blue</OPTION>
<OPTION value="#FFFF00">Yellow</OPTION>
<OPTION value="#FF00FF">Pink</OPTION>
<OPTION value="#C0C0C0">Grey</OPTION>
<OPTION value="#FF6600">Orange</OPTION>
<OPTION value="#990066">Purple</OPTION>
<OPTION value="#4682B4">Steelblue</OPTION>
<OPTION value="#DDA0DD">Plum</OPTION>
<OPTION value="#AFEEEE">Paleturquoise</OPTION>
<OPTION value="#D87093">Palevioletred</OPTION>
<OPTION value="#191970">Midnightblue</OPTION>
<OPTION value="#8A2BE2">Blue Violet</OPTION>
<OPTION value="#7FFF00">Chartreuse</OPTION>
<OPTION value="#DC143C">Crimson</OPTION>
<OPTION value="#008B8B">Dark Cyan</OPTION>
<OPTION value="#8B0000">Dark Red</OPTION>
<OPTION value="#FF1493">Deep Pink</OPTION>
</select>
<br />
<br />
Gender:<br />
<SELECT name="sexmalefemale">
<OPTION value="Boy">Boy</OPTION>
<OPTION value="Girl">Girl</OPTION>
</SELECT>
<br />
<br />
About Yourself:<br />
<textarea name="abouturself" cols=30 rows=5 wrap=physical></textarea>
<br />
<br />
<input type="hidden" name="random" value="<? echo("$rand");?>" />
Special word<br />
<input type="text" name="word" />
<input type="hidden" name="dateofjoin" value="<? print(Date("F d, Y")); ?>" />
<input type="hidden" name="msg" value="Welcome" />
<br />
<br />
Enter the number shown below<br />
<strong><? echo("$rand");?></strong><br />
<input type="text" name="rand" />
<input type="hidden" name="lastedited" value="Registered an account # <?php
/**
* Just add this in your page where you
* want the date/time to appear
*
* For more configuration options look
* in the PHP manual at http://uk2.php.net/date
*/
// Displays in the format Saturday, November 22, 2003 11.38
echo date("l, F d, Y h:i" ,time());
?> " />
<br />
<br />
<input type="submit" value="Register" />
</div>
</form>
<?
}
if($act==register)
{
$username = clean($_POST[username]);
$msg = clean($_POST[msg]);
$subject = "Welcome";
$sendto = $username;
$sentfrom = "admin";
$user = "$username";
$reason = "joining the site";
$badge = "member.png";
$display = "1";
$privmsg = $msg;
$password2 = clean($_POST[password]);
$password = md5($_POST[password]);
$email = clean($_POST[email]);
$countrywhere = clean($_POST[countrywhere]);
$avator = clean($_POST[avator]);
$sexmalefemale = clean($_POST[sexmalefemale]);
$usercolour = clean($_POST[usercolour]);
$abouturself = clean($_POST[abouturself]);
$rand = clean($_POST[rand]);
$lastedited = clean($_POST[lastedited]);
$random = $_POST[random];
$word = clean($_POST[word]);
$dateofjoin = clean($_POST[dateofjoin]);
$check = mysql_query("select * from usr_users where username = '$username'");
$check2 = mysql_num_rows($check);
if($check2==0)
{
if($username!="" && $password!="")
{
if($rand==$random)
{
$qry = mysql_query("insert into usr_pm(subject, sendto, sentfrom, privmsg) values('$subject', '$sendto', '$sentfrom', '$privmsg')");
$result = #mysql_query($qry);
$gry2 = mysql_query("insert into usr_users(username, password, word, dateofjoin, email, countrywhere, avator, sexmalefemale, usercolour, abouturself, lastedited) values('$username', '$password', '$word', '$dateofjoin', '$email', '$countrywhere', '$avator', '$sexmalefemale', '$usercolour', '$abouturself', '$lastedited')");
$result = #mysql_query($qry2);
$qry3 = mysql_query("insert into usr_badge(user, reason, badge, display) values('$user', '$reason', '$badge', '$display')");
$result = #mysql_query($qry3);
echo("You are now signed up to our site!");
if($content[emailvert]==1)
{
$emailbody = "Thanks for registering at the $content[site] usersystem! \n \n We'd like to take this chance to confirm all of your details, just so you know how to log in and get the most out of your experience! \n \n --- \n username: $username \n Password: $password2 \n Your secret code: $sec \n Your secret word: $word \n \n -- \n \n Thanks, \n $content[site] Management --";
$mail = mail($email,"Welcome to the $content[site] usersystem!", $emailbody, "From: <$content[email]>");
if(!$mail)
echo("<br />Could not send the email at this time, please check you filled out the previous page completely and try again..");
else echo("<br /></br></br><b>Please go to the email you provided to us and confirm your account, after 1 week we will suspend your account if you do not confirm.</b>");
}
}
else echo("The number you entered did not match that displayed!");
}
else echo("You have not entered filled out all the required fields, you need to do so in order to continue..");
}
else
echo("username is already in use!");
}
?>
<? }
else echo("Register disabled"); ?>
clean.php (meant strip spaces)
<?php
function clean($str)
{
$cleaned = strip_tags(htmlspecialchars(addslashes(stripslashes( $str ))));
return $cleaned;
}
?>
Functions
/*
Clean Variables
*/
function clean($str)
{
$cleaned = strip_tags(htmlspecialchars(addslashes(stripslashes( $str ))));
return $cleaned;
}
/*
End Function
*/
Thanks!
Welcome to the wonderful world of php programming!
To answer your direct question: You can use
if (substr_count($username,' ') > 0) {
// Output an appropriate error message
}
But your probably want to check that the username only consists of characters that are actually legit for a username on your site – or do you also want to be able to include any UTF character in those names?
But two more remarks:
Do look at prepared statements on inserting data into your database (mysqli_prepare()). There is a number of tutorials out on that, and it will save you many a headache, particularly if it about cleaning and binding variables.
It is generally considered good form to not only prompt for the password once, but rather twice. If the user happens to mistype the password on entry, with your solution, he will just have locked himself out of the application.
Rather than stripping spaces out and carrying on with registration, I would check for a space and then return an error to the user.
if ( strpos($username, " ") !== false ) {
/* error */
}
You could also do it client side to get the message out quickly but it must always be on the server side.
I've encounted an error, my registeration form allows users to register usernames with spaces ie, "user name" when it should be just "username" with no spaces.
I've tried searching and reading many tutorials, but most don't help me at all.
Could anyone point me in the right direction to a working tutorial, or tell me what I've done wrong.
I tried using strip the spaces, a tut but I'm not 100% how to do it.
But here is what I've done...
Register page
<?
session_start();
include("config.php");
include("clean.php");
$act = clean($_GET[act]);
$sqlcontent = mysql_query("select * from usr_config");
$content = mysql_fetch_array($sqlcontent);
$rand = rand(0,999);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="css.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Usersystem Register Page • <? echo("$content[site]");?></title>
</head>
<body>
<tr>
<? if($content[regen]==1) {
if($act!=register)
{ ?>
<form action="register_new.php?act=register" method="post">
<div align="center">Username:<br />
<input type="text" name="username" class="login" maxlength="20" />
<br />
<br />
Password:<br />
<input type="password" name="password" />
<br />
<br />
Email Address:<br />
<input type="text" name="email" />
<br />
<br />
Country:<br />
<SELECT name="countrywhere">
<option value="Afghanistan">Afghanistan</option>
<option value="Åland Islands">Åland Islands</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antarctica">Antarctica</option>
<option value="Antigua and Barbuda">Antigua and Barbuda</option>
<option value="Argentina">Argentina</option>
<option value="Armenia">Armenia</option>
<option value="Aruba">Aruba</option>
<option value="Australia">Australia</option>
<option value="Austria">Austria</option>
<option value="Azerbaijan">Azerbaijan</option>
<option value="Bahamas">Bahamas</option>
<option value="Bahrain">Bahrain</option>
<option value="Bangladesh">Bangladesh</option>
<option value="Barbados">Barbados</option>
<option value="Belarus">Belarus</option>
<option value="Belgium">Belgium</option>
<option value="Belize">Belize</option>
<option value="Benin">Benin</option>
<option value="Bermuda">Bermuda</option>
<option value="Bhutan">Bhutan</option>
<option value="Bolivia">Bolivia</option>
<option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option>
<option value="Botswana">Botswana</option>
<option value="Bouvet Island">Bouvet Island</option>
<option value="Brazil">Brazil</option>
<option value="British Indian Ocean Territory">British Indian Ocean Territory</option>
<option value="Brunei Darussalam">Brunei Darussalam</option>
<option value="Bulgaria">Bulgaria</option>
<option value="Burkina Faso">Burkina Faso</option>
<option value="Burundi">Burundi</option>
<option value="Cambodia">Cambodia</option>
<option value="Cameroon">Cameroon</option>
<option value="Canada">Canada</option>
<option value="Cape Verde">Cape Verde</option>
<option value="Cayman Islands">Cayman Islands</option>
<option value="Central African Republic">Central African Republic</option>
<option value="Chad">Chad</option>
<option value="Chile">Chile</option>
<option value="China">China</option>
<option value="Christmas Island">Christmas Island</option>
<option value="Cocos (Keeling) Islands">Cocos (Keeling) Islands</option>
<option value="Colombia">Colombia</option>
<option value="Comoros">Comoros</option>
<option value="Congo">Congo</option>
<option value="Congo, The Democratic Republic of the">Congo, The Democratic Republic of the</option>
<option value="Cook Islands">Cook Islands</option>
<option value="Costa Rica">Costa Rica</option>
<option value="Côte d'Ivoire">Côte d'Ivoire</option>
<option value="Croatia">Croatia</option>
<option value="Cuba">Cuba</option>
<option value="Cyprus">Cyprus</option>
<option value="Czech Republic">Czech Republic</option>
<option value="Denmark">Denmark</option>
<option value="Djibouti">Djibouti</option>
<option value="Dominica">Dominica</option>
<option value="Dominican Republic">Dominican Republic</option>
<option value="Ecuador">Ecuador</option>
<option value="Egypt">Egypt</option>
<option value="El Salvador">El Salvador</option>
<option value="Equatorial Guinea">Equatorial Guinea</option>
<option value="Eritrea">Eritrea</option>
<option value="Estonia">Estonia</option>
<option value="Ethiopia">Ethiopia</option>
<option value="Falkland Islands (Malvinas)">Falkland Islands (Malvinas)</option>
<option value="Faroe Islands">Faroe Islands</option>
<option value="Fiji">Fiji</option>
<option value="Finland">Finland</option>
<option value="France">France</option>
<option value="French Guiana">French Guiana</option>
<option value="French Polynesia">French Polynesia</option>
<option value="French Southern Territories">French Southern Territories</option>
<option value="Gabon">Gabon</option>
<option value="Gambia">Gambia</option>
<option value="Georgia">Georgia</option>
<option value="Germany">Germany</option>
<option value="Ghana">Ghana</option>
<option value="Gibraltar">Gibraltar</option>
<option value="Greece">Greece</option>
<option value="Greenland">Greenland</option>
<option value="Grenada">Grenada</option>
<option value="Guadeloupe">Guadeloupe</option>
<option value="Guam">Guam</option>
<option value="Guatemala">Guatemala</option>
<option value="Guinea">Guinea</option>
<option value="Guinea-Bissau">Guinea-Bissau</option>
<option value="Guyana">Guyana</option>
<option value="Haiti">Haiti</option>
<option value="Heard Island and McDonald Islands">Heard Island and McDonald Islands</option>
<option value="Holy See (Vatican City State)">Holy See (Vatican City State)</option>
<option value="Honduras">Honduras</option>
<option value="Hong Kong">Hong Kong</option>
<option value="Hungary">Hungary</option>
<option value="Iceland">Iceland</option>
<option value="India">India</option>
<option value="Indonesia">Indonesia</option>
<option value="Iran, Islamic Republic of">Iran, Islamic Republic of</option>
<option value="Iraq">Iraq</option>
<option value="Ireland">Ireland</option>
<option value="Israel">Israel</option>
<option value="Italy">Italy</option>
<option value="Jamaica">Jamaica</option>
<option value="Japan">Japan</option>
<option value="Jordan">Jordan</option>
<option value="Kazakhstan">Kazakhstan</option>
<option value="Kenya">Kenya</option>
<option value="Kiribati">Kiribati</option>
<option value="Korea, Democratic People's Republic of">Korea, Democratic People's Republic of</option>
<option value="Korea, Republic of">Korea, Republic of</option>
<option value="Kuwait">Kuwait</option>
<option value="Kyrgyzstan">Kyrgyzstan</option>
<option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option>
<option value="Latvia">Latvia</option>
<option value="Lebanon">Lebanon</option>
<option value="Lesotho">Lesotho</option>
<option value="Liberia">Liberia</option>
<option value="Libyan Arab Jamahiriya">Libyan Arab Jamahiriya</option>
<option value="Liechtenstein">Liechtenstein</option>
<option value="Lithuania">Lithuania</option>
<option value="Luxembourg">Luxembourg</option>
<option value="Macau">Macau</option>
<option value="Macedonia">Macedonia</option>
<option value="Madagascar">Madagascar</option>
<option value="Malawi">Malawi</option>
<option value="Malaysia">Malaysia</option>
<option value="Maldives">Maldives</option>
<option value="Mali">Mali</option>
<option value="Malta">Malta</option>
<option value="Marshall Islands">Marshall Islands</option>
<option value="Martinique">Martinique</option>
<option value="Mauritania">Mauritania</option>
<option value="Mauritius">Mauritius</option>
<option value="Mayotte">Mayotte</option>
<option value="Mexico">Mexico</option>
<option value="Micronesia, Federated States of">Micronesia, Federated States of</option>
<option value="Moldova, Republic of">Moldova, Republic of</option>
<option value="Monaco">Monaco</option>
<option value="Mongolia">Mongolia</option>
<option value="Montserrat">Montserrat</option>
<option value="Morocco">Morocco</option>
<option value="Mozambique">Mozambique</option>
<option value="Myanmar">Myanmar</option>
<option value="Namibia">Namibia</option>
<option value="Nauru">Nauru</option>
<option value="Nepal">Nepal</option>
<option value="Netherlands">Netherlands</option>
<option value="Netherlands Antilles">Netherlands Antilles</option>
<option value="New Caledonia">New Caledonia</option>
<option value="New Zealand">New Zealand</option>
<option value="Nicaragua">Nicaragua</option>
<option value="Niger">Niger</option>
<option value="Nigeria">Nigeria</option>
<option value="Niue">Niue</option>
<option value="Norfolk Island">Norfolk Island</option>
<option value="Northern Mariana Islands">Northern Mariana Islands</option>
<option value="Norway">Norway</option>
<option value="Oman">Oman</option>
<option value="Pakistan">Pakistan</option>
<option value="Palau">Palau</option>
<option value="Palestinian Territory, Occupied">Palestinian Territory, Occupied</option>
<option value="Panama">Panama</option>
<option value="Papua New Guinea">Papua New Guinea</option>
<option value="Paraguay">Paraguay</option>
<option value="Peru">Peru</option>
<option value="Philippines">Philippines</option>
<option value="Pitcairn">Pitcairn</option>
<option value="Poland">Poland</option>
<option value="Portugal">Portugal</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Qatar">Qatar</option>
<option value="Réunion">Réunion</option>
<option value="Romania">Romania</option>
<option value="Russian Federation">Russian Federation</option>
<option value="Rwanda">Rwanda</option>
<option value="Saint Helena">Saint Helena</option>
<option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option>
<option value="Saint Lucia">Saint Lucia</option>
<option value="Saint Pierre and Miquelon">Saint Pierre and Miquelon</option>
<option value="Saint Vincent and the Grenadines">Saint Vincent and the Grenadines</option>
<option value="Samoa">Samoa</option>
<option value="San Marino">San Marino</option>
<option value="Sao Tome and Principe">Sao Tome and Principe</option>
<option value="Saudi Arabia">Saudi Arabia</option>
<option value="Senegal">Senegal</option>
<option value="Serbia and Montenegro">Serbia and Montenegro</option>
<option value="Seychelles">Seychelles</option>
<option value="Sierra Leone">Sierra Leone</option>
<option value="Singapore">Singapore</option>
<option value="Slovakia">Slovakia</option>
<option value="Slovenia">Slovenia</option>
<option value="Solomon Islands">Solomon Islands</option>
<option value="Somalia">Somalia</option>
<option value="South Africa">South Africa</option>
<option value="Spain">Spain</option>
<option value="Sri Lanka">Sri Lanka</option>
<option value="Sudan">Sudan</option>
<option value="Suriname">Suriname</option>
<option value="Svalbard and Jan Mayen">Svalbard and Jan Mayen</option>
<option value="Swaziland">Swaziland</option>
<option value="Sweden">Sweden</option>
<option value="Switzerland">Switzerland</option>
<option value="Syrian Arab Republic">Syrian Arab Republic</option>
<option value="Taiwan, Province of China">Taiwan, Province of China</option>
<option value="Tajikistan">Tajikistan</option>
<option value="Tanzania, United Republic of">Tanzania, United Republic of</option>
<option value="Thailand">Thailand</option>
<option value="Timor-Leste">Timor-Leste</option>
<option value="Togo">Togo</option>
<option value="Tokelau">Tokelau</option>
<option value="Tonga">Tonga</option>
<option value="Trinidad and Tobago">Trinidad and Tobago</option>
<option value="Tunisia">Tunisia</option>
<option value="Turkey">Turkey</option>
<option value="Turkmenistan">Turkmenistan</option>
<option value="Turks and Caicos Islands">Turks and Caicos Islands</option>
<option value="Tuvalu">Tuvalu</option>
<option value="Uganda">Uganda</option>
<option value="Ukraine">Ukraine</option>
<option value="United Arab Emirates">United Arab Emirates</option>
<option value="United Kingdom">United Kingdom</option>
<option value="United States">United States</option>
<option value="United States Minor Outlying Islands">United States Minor Outlying Islands</option>
<option value="Uruguay">Uruguay</option>
<option value="Uzbekistan">Uzbekistan</option>
<option value="Vanuatu">Vanuatu</option>
<option value="Venezuela">Venezuela</option>
<option value="Viet Nam">Viet Nam</option>
<option value="Virgin Islands, British">Virgin Islands, British</option>
<option value="Virgin Islands, U.S.">Virgin Islands, U.S.</option>
<option value="Wallis and Futuna">Wallis and Futuna</option>
<option value="Western Sahara">Western Sahara</option>
<option value="Yemen">Yemen</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</SELECT>
<br />
<br />
Username Colour:<br />
<select name="usercolour">
<OPTION value="#000000">Black</OPTION>
<OPTION value="#FF0000">Red</OPTION>
<OPTION value="#00FF00">Green</OPTION>
<OPTION value="#0000FF">Blue</OPTION>
<OPTION value="#FFFF00">Yellow</OPTION>
<OPTION value="#FF00FF">Pink</OPTION>
<OPTION value="#C0C0C0">Grey</OPTION>
<OPTION value="#FF6600">Orange</OPTION>
<OPTION value="#990066">Purple</OPTION>
<OPTION value="#4682B4">Steelblue</OPTION>
<OPTION value="#DDA0DD">Plum</OPTION>
<OPTION value="#AFEEEE">Paleturquoise</OPTION>
<OPTION value="#D87093">Palevioletred</OPTION>
<OPTION value="#191970">Midnightblue</OPTION>
<OPTION value="#8A2BE2">Blue Violet</OPTION>
<OPTION value="#7FFF00">Chartreuse</OPTION>
<OPTION value="#DC143C">Crimson</OPTION>
<OPTION value="#008B8B">Dark Cyan</OPTION>
<OPTION value="#8B0000">Dark Red</OPTION>
<OPTION value="#FF1493">Deep Pink</OPTION>
</select>
<br />
<br />
Gender:<br />
<SELECT name="sexmalefemale">
<OPTION value="Boy">Boy</OPTION>
<OPTION value="Girl">Girl</OPTION>
</SELECT>
<br />
<br />
About Yourself:<br />
<textarea name="abouturself" cols=30 rows=5 wrap=physical></textarea>
<br />
<br />
<input type="hidden" name="random" value="<? echo("$rand");?>" />
Special word<br />
<input type="text" name="word" />
<input type="hidden" name="dateofjoin" value="<? print(Date("F d, Y")); ?>" />
<input type="hidden" name="msg" value="Welcome" />
<br />
<br />
Enter the number shown below<br />
<strong><? echo("$rand");?></strong><br />
<input type="text" name="rand" />
<input type="hidden" name="lastedited" value="Registered an account # <?php
/**
* Just add this in your page where you
* want the date/time to appear
*
* For more configuration options look
* in the PHP manual at http://uk2.php.net/date
*/
// Displays in the format Saturday, November 22, 2003 11.38
echo date("l, F d, Y h:i" ,time());
?> " />
<br />
<br />
<input type="submit" value="Register" />
</div>
</form>
<?
}
if($act==register)
{
$username = clean($_POST[username]);
$username = str_replace (" ", "", $username);
$msg = clean($_POST[msg]);
$subject = "Welcome";
$sendto = $username;
$sentfrom = "admin";
$user = "$username";
$reason = "joining the site";
$badge = "member.png";
$display = "1";
$privmsg = $msg;
$password2 = clean($_POST[password]);
$password = md5($_POST[password]);
$email = clean($_POST[email]);
$countrywhere = clean($_POST[countrywhere]);
$avator = clean($_POST[avator]);
$sexmalefemale = clean($_POST[sexmalefemale]);
$usercolour = clean($_POST[usercolour]);
$abouturself = clean($_POST[abouturself]);
$rand = clean($_POST[rand]);
$lastedited = clean($_POST[lastedited]);
$random = $_POST[random];
$word = clean($_POST[word]);
$dateofjoin = clean($_POST[dateofjoin]);
$check = mysql_query("select * from usr_users where username = '$username'");
$check2 = mysql_num_rows($check);
if($check2==0)
{
if($username!="" && $password!="")
{
if($rand==$random)
{
$qry = mysql_query("insert into usr_pm(subject, sendto, sentfrom, privmsg) values('$subject', '$sendto', '$sentfrom', '$privmsg')");
$result = #mysql_query($qry);
$gry2 = mysql_query("insert into usr_users(username, password, word, dateofjoin, email, countrywhere, avator, sexmalefemale, usercolour, abouturself, lastedited) values('$username', '$password', '$word', '$dateofjoin', '$email', '$countrywhere', '$avator', '$sexmalefemale', '$usercolour', '$abouturself', '$lastedited')");
$result = #mysql_query($qry2);
$qry3 = mysql_query("insert into usr_badge(user, reason, badge, display) values('$user', '$reason', '$badge', '$display')");
$result = #mysql_query($qry3);
echo("You are now signed up to our site!");
if($content[emailvert]==1)
{
$emailbody = "Thanks for registering at the $content[site] usersystem! \n \n We'd like to take this chance to confirm all of your details, just so you know how to log in and get the most out of your experience! \n \n --- \n username: $username \n Password: $password2 \n Your secret code: $sec \n Your secret word: $word \n \n -- \n \n Thanks, \n $content[site] Management --";
$mail = mail($email,"Welcome to the $content[site] usersystem!", $emailbody, "From: <$content[email]>");
if(!$mail)
echo("<br />Could not send the email at this time, please check you filled out the previous page completely and try again..");
else echo("<br /></br></br><b>Please go to the email you provided to us and confirm your account, after 1 week we will suspend your account if you do not confirm.</b>");
}
}
else echo("The number you entered did not match that displayed!");
}
else echo("You have not entered filled out all the required fields, you need to do so in order to continue..");
}
else
echo("username is already in use!");
}
?>
<? }
else echo("Register disabled"); ?>
clean.php (meant strip spaces)
<?php
function clean($str)
{
$cleaned = strip_tags(htmlspecialchars(addslashes(stripslashes( $str ))));
return $cleaned;
}
?>
Functions
/*
Clean Variables
*/
function clean($str)
{
$cleaned = strip_tags(htmlspecialchars(addslashes(stripslashes( $str ))));
return $cleaned;
}
/*
End Function
*/
Thanks!
$str = str_replace(" ", "", $str);
will remove all spaces.
Additionally, my PHP is a little rusty but doesn't stripslashes do the inverse of addslashes, therefore doing one then the other is doing nothing?
So what you are looking for is "form validation".
You don't want accept an input unless it confirms to your concept of what's valid.
You have two levels where you can check for validation: one the client side (through javascript) and on the server side.
On the client side you could use something like the jQuery form validation plugin:
http://docs.jquery.com/Plugins/Validation
On the server side you could use the substr_count() function.
http://www.php.net/manual/en/function.substr-count.php
Do a str_replace(' ', '', $string) This will take 'user name' and return username. Easiest would be doing it in php unless you don't want users to do it. Then use javascript with.
function checkform(){
var username = $('form[name = username]').val()
var re = /\s/g;
if(re.test(username)){
alert("You can't have a space")
return false;
}
}
To explain:
first we get the username input value and put it in a variable. Then we test the username to see if it contains an spaces /s. If it does have a space then we alert them. the var re checks for a space in the string using the test method. Return False stops the form from submitting. You from would look like
<form onsubmit="checkfrom()">
Does that help explain it. I'm doing it from memory so might be off.
For just spaces, use str_replace
$string = str_replace(' ', '', $string);
For all white space, use preg_replace
$string = preg_replace('/\s+/', '', $string);
The function trim should work. :)