Colonel_Ingus Posted September 26, 2011 Share Posted September 26, 2011 Hi, I'm new here, desperate for a fix on this script, really hope someone can help. It submits, then goes right back to the same empty form. I added: error_reporting(E_ALL); ini_set('display_errors', '1'); to the top of the page and I get that line 7 has an unidentified mode. Here is the script, any help would be amazing, thank you: <? include("codelibrary/connection.php"); include("codelibrary/functions.php"); error_reporting(E_ALL); ini_set('display_errors', '1'); $pagename="home"; if($_POST['mode']=='register') { $firstname = $_POST['First_Name']; $lastname = $_POST['Last_Name']; $email = $_POST['email']; $password = $_POST['password']; $sex = $_POST['sex']; $Zipcode = $_POST['Zipcode']; $month = $_POST['Month']; $date = $_POST['Date']; $year = $_POST['Year']; $Birthday = $date."-".$month."-".$year; $sql2 = mysql_query("select * from tbl_registration where user_email='".$email."'"); $row2 = mysql_num_rows($sql2); if($row2) { $_SESSION['Msg']="Email Already Exist."; header("location:sign-in.php"); exit(); }else{ $sql = "insert into tbl_registration SET first_name='".$firstname."' , last_name='".$lastname."' , user_email='".$email."' , user_password='".$password."' , sex='".$sex."' , zipcode='".$Zipcode."' , birthday='".$Birthday."',published=1"; mysql_query($sql); $insert_id=mysql_insert_id(); if($sex == '1'){ $sex= "Male"; }else{ $sex= "Female"; } $mail_for="Registration_mail"; $forgot_pass=@mysql_fetch_array(mysql_query("select * from tbl_mail Where mail_for='".$mail_for."'")); $to= $email; $subject=$forgot_pass['title']; $content=$forgot_pass['content']; $content=str_replace("#Firstname#",$firstname,$content); $content=str_replace("#Lastname#",$lastname,$content); $content=str_replace("#Username#",$to,$content); $content=str_replace("#Password#",$password,$content); $content=str_replace("#gender#",$sex,$content); $content=str_replace("#Zipcode#",$Zipcode,$content); $content=str_replace("#Birthday#",$Birthday,$content); $headers4sender_user = "MIME-Version: 1.0\r\n"; $headers4sender_user .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers4sender_user .= "From: <[email protected]>\r\n"; $headers4sender_user .= "X-Mailer: PHP's mail() Function\n"; mail($to,$subject,$content,$headers4sender_user); $content=""; $subject="";$to=""; $_SESSION['Msg']="Registered Successfully."; } $_SESSION['user_id']=$insert_id; header("location:devis_home.php"); exit(); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script language="javascript"> function hidedivnew() { document.getElementById('light2').style.display='none' document.getElementById('fade2').style.display='none' } function showdivnew() { document.getElementById('light2').style.display='block' document.getElementById('fade2').style.display='block' } </script> <style> .black_overlay{ display: none; position:fixed; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80); } .white_content { display:none; position:fixed; top: 23%; left: 28%; width: 30%; height: 32%; padding: 10px; border: 10px solid #de5b31; background-color: white; z-index:1200; color:#999999; } </style> <? include("includes/head.php");?> </head> <body style="background:url(images/bricks_new2.png) left top no-repeat;"> <div id="main_container"> <!-- ////////////////////////////////////////////////////HEADDER//////////////////////////////////////////////////// --> <? include("includes/header_main.php");?> <!-- //////////////////////////////////////////////////HEADDER END////////////////////////////////////////////////// --> <!-- /////////////////////////////////////////////////SUBCONTAINER///////////////////////////////////////////////// --> <div id="sub_container" style="height:528px; padding:10px 50px 0px 50px;"> <div class="container" style="width:952px; margin:auto; padding:60px 0px; *height:408px; "> <form method="post" action="" name="registration_form" onSubmit="return chkvalidation();"> <div id="bform"> <img src="images/become_title1.jpg"> <ul> <li><label>First Name</label><input type="text" name="First_Name" id="First_Name" class="txt"></li> <li><label>Last Name</label><input type="text" name="Last_Name" id="Last_Name" class="txt"></li> <li><label>Email</label><input type="text" name="email" id="email" class="txt"></li> <li><label>Zipcode</label><input type="text" name="Zipcode" id="Zipcode" class="txt" maxlength="5"></li> <li><label>Password</label><input type="password" name="password" id="password" class="txt"></li> <li><label>Confirm Password</label><input type="password" name="con_password" id="con_password" class="txt"></li> <li> <ul id="date"> <li><label>MM</label><input type="text" name="Month" id="Month" class="text" maxlength="2"></li> <li><label>DD</label><input type="text" name="Date" id="Date" class="text" maxlength="2"></li> <li><label>YYYY</label><input type="text" name="Year" id="Year" style="width:50px;" class="text" maxlength="4"></li> </ul> </li> <li class="gender"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><input type="radio" name="sex" value="1" style="width:20px;"></td> <td>Male</td> <td><input type="radio" name="sex" value="0" style="width:20px;"></td> <td>Female</td> </tr> </table> </li> </ul> <div class="clear"> </div> <center> <input type="image" src="images/thanks_btn.jpg"> <br><br> <a href="index.php">Already a member?</a> </center> </div></form> </div> </div> <!-- ////////////////////////////////////////////////////FOOTER//////////////////////////////////////////////////// --> <? include("includes/footer.php");?> <!-- //////////////////////////////////////////////////FOOTER END////////////////////////////////////////////////// --> </div> </body> </html> <script language="javascript"> function chkvalidation() { var First_Name=document.getElementById('First_Name').value; var Last_Name=document.getElementById('Last_Name').value; var email=document.getElementById('email').value; var password=document.getElementById('password').value; var con_password=document.getElementById('con_password').value; var pass_length=document.getElementById('password').value.length; var Zipcode=document.getElementById('Zipcode').value; var month=document.getElementById('Month').value; var month_len=document.getElementById('Month').value.length; var date=document.getElementById('Date').value; var date_len=document.getElementById('Date').value.length; var year=document.getElementById('Year').value; var year_len=document.getElementById('Year').value.length; var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; if(First_Name=='' || First_Name=='First Name') { alert("Please Enter First Name"); document.getElementById('First_Name').focus(); return false; } if(Last_Name=='' || Last_Name=='Last Name') { alert("Please Enter Last Name"); document.getElementById('Last_Name').focus(); return false; } if(email=='' || email=='Email Address') { alert("Please Enter Email Address"); document.getElementById('email').focus(); return false; } if(reg.test(email) == false) { alert('Please Enter Valid Email Address'); document.getElementById('email').focus(); return false; } if(password=='' || password=='Password') { alert("Please Enter Password"); document.getElementById('password').focus(); return false; } if(con_password=='' || con_password=='Password' || con_password!=password) { alert("Password and Confirm Password are not matching."); document.getElementById('con_password').focus(); return false; } if(pass_length < 4 || pass_length > 16) { alert("Please enter 4-character minimum. 16-character maximum for password"); document.getElementById('password').focus(); return false; } if(Zipcode=='' || Zipcode=='Zipcode') { alert("Please Enter Zip Code"); document.getElementById('Zipcode').focus(); return false; } if(isNaN(Zipcode)) { alert("Zip Code is Not Valid "); document.getElementById('Zipcode').focus(); return false; } if((month=='') || (month=='MM')) { alert("Please Type Month"); document.getElementById('Month').focus(); return false; } if((month_len<2) || (month_len>2)) { alert("Please Type Correct month"); document.getElementById('Month').focus(); return false; } if((date=='') || (date=='DD')) { alert("Please Type Date"); document.getElementById('Date').focus(); return false; } if((date_len<2) || (date_len>2)) { alert('Please Type Correct Date'); document.getElementById('Date').focus(); return false; } if((year=='') || (year=='YYYY')) { alert("Please Type Year"); document.getElementById('Year').focus(); return false; } if((year_len<4) || (year_len>4)) { alert("Please Type Correct year"); document.getElementById('Year').focus(); return false; } return true; } </script> Link to comment https://forums.phpfreaks.com/topic/247884-trying-to-repair-someone-elses-registration-form-code/ Share on other sites More sharing options...
will35010 Posted September 26, 2011 Share Posted September 26, 2011 I don't see anything in your form that sends a POST request with the mode info. You need something like this in your HTML form: <input type="hidden" id="mode" name="mode" value="register" /> Link to comment https://forums.phpfreaks.com/topic/247884-trying-to-repair-someone-elses-registration-form-code/#findComment-1272987 Share on other sites More sharing options...
Colonel_Ingus Posted September 26, 2011 Author Share Posted September 26, 2011 You're the best, thank you so much. Link to comment https://forums.phpfreaks.com/topic/247884-trying-to-repair-someone-elses-registration-form-code/#findComment-1272996 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.