Jump to content

form data cant insert now..


thara

Recommended Posts

Hi.. everyone..

 

I have a problem in my php form now. Earlier it worked properly. It mean I registered 7 institutes and it was no problem the form worked very well. But when I try to register my 8 institute using same php script I cant register it. It is very confusing for me and I cant think actually what has happen. There is no error message as well.

 

This is my form

 

]http://www.lankainstitute.com/centersignup/institute_registration_form.php[/b] 

 

can anybody tell me what has happen?

 

any comments are greatly appreciated.

 

Thank YOu.

Link to comment
Share on other sites

What is the code around the line 314 of the institute_registration_form.php

 

'/home/www/lankainstitute.com/centersignup/institute_registration_form.php' on line 314: Undefined index: category 

'/home/www/lankainstitute.com/centersignup/institute_registration_form.php' on line 314: Invalid argument supplied for foreach() 

Link to comment
Share on other sites

The category seem to be mssing from the form drop down so you cannot select them maybe  look at the code and see why they are missing

Undefined index: category

 

 

City option is missing from the send form as I can see it

 

  [district] => 3
            [tel] =>

 

The array should be

  [district] => 3
        [city] =>
            [tel] =>

Link to comment
Share on other sites

 

This is my php code...

 

	if (empty($reg_errors)) { // If everything's OK...

	// Make sure the email address and username are available:
	$qy = "SELECT email FROM login WHERE email='$email'";
	$re = mysqli_query ($dbc, $qy);

	// Get the number of rows returned:
	$rows = mysqli_num_rows($re);

	if ($rows == 0) { // No problems!

		// Add the login details to the database...		
		$qy1 = "INSERT INTO login (email, password, login_level, last_login) 
				VALUES ('$email', SHA1('$pass'), 2, now() )"; 

		$re1 = mysqli_query ($dbc, $qy1);

		if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.

			$loginId = mysqli_insert_id($dbc); 

			// Add the address details to the database...		
			$q1 = "INSERT INTO address (address_one, address_two, city_id ) 
				VALUES ('$address1', '$address2', '$cityId' )"; 

			$r1 = mysqli_query ($dbc, $q1);

			if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.

				$addressId = mysqli_insert_id($dbc); 

				// Add the contact details to the database...		
				$q2 = "INSERT INTO contact (telephone, mobile, email, web_address, fb_address, twitter_address, google_address, best_time_call, privacy_setting ) 
					 VALUES ('$tel', '$mobile', '$email', '$web', '$facebook', '$twitter', '$google', '$bestTime', '$privacy' )"; 

				$r2 = mysqli_query ($dbc, $q2);	

				if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.

					$contactId = mysqli_insert_id($dbc); 

					// Auto Generating the Institute Code 
					$q3 = 'SELECT institute_code FROM institutes ORDER BY registration_date DESC LIMIT 1';
					$r3 = @mysqli_query ($dbc, $q3);

					if  ( mysqli_num_rows($r3) == 1 )   { // Valid login ID.
						$row = mysqli_fetch_array ($r3, MYSQLI_ASSOC);					
						$instituteCode = $row['institute_code'];						
						$instituteCode += 1;
					} else {						
						$instituteCode = 1200;
					} 

					// Create the activation code:
					$active = md5(uniqid(rand(), true));						

					$q4 = "INSERT INTO institutes ( login_id, address_id, contact_id, institute_code, institute_name, institute_slogan, introduction_note, institute_history, institute_present, active, registration_date ) 
						 VALUES ( '$loginId', '$addressId', '$contactId', '$instituteCode', '$insName', '$Slogan', '$instroduction', '$history', '$present', '$active', NOW() )";

					$r4 = mysqli_query ($dbc, $q4);	

					if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.

						$instituteId = mysqli_insert_id($dbc); 

						// Send the email:
						$body = "Thank you for registering at www.lankainstitute.com website. 
								To activate your institute profile, please click on this link:\n\n";

						$body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$active";

						mail( 'admin@lankainstitute.com', 'Institute Profile: Registration Confirmation', $body, 'From: ' . $email . '');	


						foreach( $medium as $value){
							$q = "INSERT INTO institute_medium ( medium_id, institute_id ) 
								 VALUES ( '$value', '$instituteId' )"; 					
							$r = mysqli_query ($dbc, $q); 										
						}	

						foreach( $group as $value){
							$q = "INSERT INTO institute_option ( option_id, institute_id )
								 VALUES ( '$value', '$instituteId' )"; 					
							$r = mysqli_query ($dbc, $q); 										
						}

						foreach( $_SESSION['category'] as $value ) {	

						$q = "INSERT INTO institute_category ( institute_id, category_id ) VALUES ( ?, ? )";
						$stmt = mysqli_prepare( $dbc, $q );
						mysqli_stmt_bind_param( $stmt, 'ii', $instituteId, $value ); 
						mysqli_stmt_execute( $stmt ); 						
						}		

						unset($_SESSION['category']); 

						// Clear $_POST:
						$_POST = array(); 							

						$url = 'http://localhost/lanka_institute/centersignup/register_success.php'; // Define the URL:		
						ob_end_clean(); // Delete the buffer.
						header("Location: $url");
						exit(); // Quit the script.		

						// Print a message: 						
						//echo '<span style="text-transform: uppercase; font-weight: bold;">Your Institute has been added to the Lanka Institute Web Site.</span>'; 


					}							
				} 
			} 
		} 

	} else { // The email address or username is not available.

		$reg_errors['email'] = 'This email address has already been registered. Try again with a different email';			

	} // End of $rows == 0 IF.
} // End of empty($reg_errors) IF

 

Data insert to login, address, contact table very well. But data is not inserting to institute table. It works earlier but now it is not. Anybody can tell me where I have gone wrong....

 

Thank you.

Link to comment
Share on other sites

Which query isn't working? This one?

	

$q4 = "INSERT INTO institutes ( login_id, address_id, contact_id, institute_code, institute_name, institute_slogan, introduction_note, institute_history, institute_present, active, registration_date )
VALUES ( '$loginId', '$addressId', '$contactId', '$instituteCode', '$insName', '$Slogan', '$instroduction', '$history', '$present', '$active', NOW() )";

 

Have you checked if there is a MySQL error?

$r4 = mysqli_query ($dbc, $q4) or die ('MySQL error!<br />Query: ' . $q4 . '<br />Error: ' . mysqli_error($dbc));

Link to comment
Share on other sites

code is not execute in this if loop.. 'if (mysqli_affected_rows($dbc) == 1) { // If it ran OK'. But this loop working properly in localhost..

 

					if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.

					$contactId = mysqli_insert_id($dbc); 

					// Auto Generating the Institute Code 
					$q3 = 'SELECT institute_code FROM institutes ORDER BY registration_date DESC LIMIT 1';
					$r3 = @mysqli_query ($dbc, $q3);

					if  ( mysqli_num_rows($r3) == 1 )   { // Valid login ID.
						$row = mysqli_fetch_array ($r3, MYSQLI_ASSOC);					
						$instituteCode = $row['institute_code'];						
						$instituteCode += 1;
					} else {						
						$instituteCode = 1200;
					} 

					// Create the activation code:
					$active = md5(uniqid(rand(), true));						

					$q4 = "INSERT INTO institutes ( login_id, address_id, contact_id, institute_code, institute_name, institute_slogan, introduction_note, institute_history, institute_present, active, registration_date ) 
						 VALUES ( '$loginId', '$addressId', '$contactId', '$instituteCode', '$insName', '$Slogan', '$instroduction', '$history', '$present', '$active', NOW() )";

					$r4 = mysqli_query ($dbc, $q4);	

					if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.

						$instituteId = mysqli_insert_id($dbc); 

						// Send the email:
						$body = "Thank you for registering at www.lankainstitute.com website. 
								To activate your institute profile, please click on this link:\n\n";

						$body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$active";

						mail( 'admin@lankainstitute.com', 'Institute Profile: Registration Confirmation', $body, 'From: ' . $email . '');	


						foreach( $medium as $value){
							$q = "INSERT INTO institute_medium ( medium_id, institute_id ) 
								 VALUES ( '$value', '$instituteId' )"; 					
							$r = mysqli_query ($dbc, $q); 										
						}	

						foreach( $group as $value){
							$q = "INSERT INTO institute_option ( option_id, institute_id )
								 VALUES ( '$value', '$instituteId' )"; 					
							$r = mysqli_query ($dbc, $q); 										
						}

						foreach( $_SESSION['category'] as $value ) {	

						$q = "INSERT INTO institute_category ( institute_id, category_id ) VALUES ( ?, ? )";
						$stmt = mysqli_prepare( $dbc, $q );
						mysqli_stmt_bind_param( $stmt, 'ii', $instituteId, $value ); 
						mysqli_stmt_execute( $stmt ); 						
						}		

						unset($_SESSION['category']); 

						// Clear $_POST:
						$_POST = array(); 							

						$url = 'http://www.lankainstitute.com/centersignup/register_success.php'; // Define the URL:		
						ob_end_clean(); // Delete the buffer.
						header("Location: $url");
						exit(); // Quit the script.		

						// Print a message: 						
						//echo '<span style="text-transform: uppercase; font-weight: bold;">Your Institute has been added to the Lanka Institute Web Site.</span>'; 


					}							
				}

 

 

But data is inserting into contact table.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.