prcollin Posted July 23, 2007 Share Posted July 23, 2007 <?php include("connect.php"); //first check to see if user submits [color=red]if (!isset($_POST[submit])) {[/color] //if the submit button is not pushed, show the form $show_form = "yes"; } elseif (isset($_POST[submit])) { //if the submit button is pushed, check errors if (empty($_POST[username])) { //show the form $show_form = "yes"; //…and so on with the errors } else { //after no more error checks, if user passes all $show_success = "yes"; } //end if } //end if ->you can put if statements inside if statements //if show form is true …then display it if ($show_form == "yes") { $display = "<center>"; $display .= "<form action = \[color=green]"$_SERVER[php_SELF][/color]\" method = \"post\">\n"; $display .= "<table border = >"; $display .= "<td align = \"right\">Company Name:</td>\n"; $display .= "<td><input type = \"text\" name = \"company_name\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">Address:</td>\n"; $display .= "<td><input type = \"text\" name = \"address\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">City:</td>\n"; $display .= "<td><input type = \"text\" name = \"city\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">State:</td>\n"; $display .= "<td><input type = \"text\" name = \"state\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">Zip Code:</td>\n"; $display .= "<td><input type = \"text\" name = \"zip_code\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">Phone Number:</td>\n"; $display .= "<td><input type = \"text\" name = \"phone\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">Fax:</td>\n"; $display .= "<td><input type = \"text\" name = \"fax\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n"; $display .= "<td align = \"right\">E-mail Address:</td>\n"; $display .= "<td><input type = \"text\" name = \"email\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">Chose a User Name:</td>\n"; $display .= "<td><input type = \"text\" name = \"user_name\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">Choose A Password:</td>\n"; $display .= "<td><input type = \"password\" name = \"password\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">Re-Type Password:</td>\n"; $display .= "<td><input type = \"password\" name = \"pass2\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">Type A Security Question:</td>\n"; $display .= "<td><input type = \"text\" name = \"security_question\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">Type A Security Question Answer:</td>\n"; $display .= "<td><input type = \"text\" name = \"security_questionans\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">Please Choose a Subdomain Name:</td>\n"; $display .= "<td><input type = \"text\" name = \"subdomain_choice\" size = 20 maxlength = 50></td>\n"; $display .= "</tr>\n\n"; $display .= "<td align = \"right\">Please choose a business category:</td>\n"; $display .= "<td><input type = \"text\" name = \"category\" size = 20 maxlength = 50></td>\n"; $display .= "<td><input type = \"submit\" name = \"submit\" value = \"Register\"></td>\n"; $display .= "</tr>\n"; $display .= "</table>\n"; $display .= "</form>\n"; $display .= "</center>\n"; } //if [color=red]if ($show_success == "yes") {[/color] $company_name = ($_POST[company_name]); $address = ($_POST[address]); $city = ($_POST[city]); $state = ($_POST[state]); $zip_code = ($_POST[zip_code]); $phone = ($_POST[phone]); $fax = ($_POST[fax]); $email = ($_POST[email]); $user_name = ($_POST[user_name]); $password = ($_POST[password]); $pass2 = ($_POST[pass2]); $security_question = ($_POST[sercurity_question]); $security_questionans = ($_POST[security_questionans]); $subdomain_choice = ($_POST[subdomain_choice]); $category_type = ($_POST[category]); $query = "INSERT INTO newclients (company_name, address, city, state, zipe_code, phone, fax, email, user_name, password, pass2, security_question, security_questionans, sub_domain) VALUES('$company_name', '$address', '$city', '$state', '$zip_code','$phone', '$fax', '$email', '$user_name', '$password', '$pass2','$security_question','$security_questionans', '$subdomain_choice', NOW())"; $result = mysql_query($query) or die(mysql_error()); } //end if ?> <html> <head> <title>New Customer Sign Up Form</title> </head> <body> <h3>New Customer Sign Up Form</h3> <p><?php print "$display"; ?></p> </body> </html> here are the errors 1. Use of undefined constant submit. assumed 'submit' 2. Use of undefined constant Show_success ok guess those are the only two how do i define them so they will do what i needd them too. I need this form to post to a database. SHould i take out the Php_self part also that is higlighted in green and does anyone have any other suggestions how to get this to actually work. Quote Link to comment Share on other sites More sharing options...
per1os Posted July 23, 2007 Share Posted July 23, 2007 $_POST['submit'] Add quotes to array indexes or else they are considered constants. Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 23, 2007 Share Posted July 23, 2007 also use heredoc i am sure this code was posted before and wildteen helped sure of it? Quote Link to comment Share on other sites More sharing options...
prcollin Posted July 23, 2007 Author Share Posted July 23, 2007 also use heredoc i am sure this code was posted before and wildteen helped sure of it? it was posted with different errors and it was never solved. And i have no clue what heredoc is i am a noob Quote Link to comment Share on other sites More sharing options...
simcoweb Posted July 23, 2007 Share Posted July 23, 2007 Basically heredoc replaces the need to use the $display variable name on all those lines. You do it like: $display = <<<EOF all the code for display goes here EOF; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.