Form data to MySql

This is a discussion on "Form data to MySql" within the Introduce Yourself section. This forum, and the thread "Form data to MySql are both part of the Community category.



Go Back   Webforumz.com > Community > Introduce Yourself

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 7th, 2006, 19:22
casper22
Guest
Posts: n/a
Unhappy Form data to MySql

Hello everyone,

I hope somebody can help me. I have an online form which directs to a confirmation page then to a thank you page after a new member completes the information needed. This is in the format of PHP.

Email is then sent to the new member and to me about the new member's information.

Here is the problem, the data collected in the online form does not save to the MySql database located in the host server.

I must have made a mistake somewhere.

Please advise.

Best regards,

Mike
Reply With Quote

  #2 (permalink)  
Old Aug 7th, 2006, 19:56
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,761
Blog Entries: 1
Thanks: 0
Thanked 18 Times in 18 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: Form data to MySql

Would need some code to look at. Stripped of passwords etc of course if any.
__________________
The internet is just a fad.
http://www.mevans76.com
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Reply With Quote
  #3 (permalink)  
Old Aug 7th, 2006, 20:05
casper22
Guest
Posts: n/a
Re: Form data to MySql

Here is the code from the confirmation page....


<?php require_once('Connections/connPNAUK.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO information (SURNAME, FIRSTNAME, EMAIL, MIDDLENAME, DOB, MEMBER_CATEGORY, PNA_UK_EXPIRY, ADDRESS1, TOWN, COUNTY, POSTCODE, MOBILE_NUMBER, LANDLINE, UNIVERSITY, YEAR_GRAD, HIGHEST_EDUC, PRC_NUMBER, PRC_EXPIRY, BENEFICIARY, RELATIONSHIP, BENEFICIARY_ADDRESS, BENEFICIARY_CONTACT, HOSPITAL_OF_WORK, AREA_OF_WORK, `POSITION`, WORK_ADDRESS) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['surname'], "text"),
GetSQLValueString($_POST['firstname'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['middlename'], "text"),
GetSQLValueString($_POST['dob'], "text"),
GetSQLValueString($_POST['membership'], "text"),
GetSQLValueString($_POST['PNA_UK_EXPIRY'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['townI'], "text"),
GetSQLValueString($_POST['county'], "text"),
GetSQLValueString($_POST['postcode'], "text"),
GetSQLValueString($_POST['mobile1'], "text"),
GetSQLValueString($_POST['mobile2'], "text"),
GetSQLValueString($_POST['university'], "text"),
GetSQLValueString($_POST['yeargrad'], "text"),
GetSQLValueString($_POST['educationI'], "text"),
GetSQLValueString($_POST['prcid'], "text"),
GetSQLValueString($_POST['prcexpiry'], "text"),
GetSQLValueString($_POST['nok'], "text"),
GetSQLValueString($_POST['relationship'], "text"),
GetSQLValueString($_POST['nokaddress'], "text"),
GetSQLValueString($_POST['nokcontactnumber'], "text"),
GetSQLValueString($_POST['employer'], "text"),
GetSQLValueString($_POST['areaofwork'], "text"),
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['employeraddress'], "text"));
mysql_select_db($database_connPNAUK, $connPNAUK);
$Result1 = mysql_query($insertSQL, $connPNAUK) or die(mysql_error());
$insertGoTo = "thankyou.php";


if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$exp_dt_func = mktime(0, 0, 0, date("m"), date("d"), date("y")+1);
$exp_dt = date("d-M-y", $exp_dt_func);
?>
Reply With Quote
  #4 (permalink)  
Old Aug 7th, 2006, 20:08
casper22
Guest
Posts: n/a
Re: Form data to MySql

another code which is supposed to write to the mysql...


<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_connPNAUK = "mysql8.streamline.net";
$database_connPNAUK = "databasname";
$table_connPNAUK = "tablename";
$username_connPNAUK = "username";
$password_connPNAUK = "password";
$connPNAUK = mysql_connect ("mysql8.streamline.net","databasename","password" ) or trigger_error(mysql_error(),E_USER_ERROR);
?>
Reply With Quote
  #5 (permalink)  
Old Aug 8th, 2006, 21:30
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Form data to MySql

Have you tried printing out the errors returned from your attempts to communicate with the database?

I'm assuming if your info isn't getting into the database, there is an error being generated somewhere along the way.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql data loads once user login longstand PHP Forum 9 Feb 7th, 2008 07:10
Sending Form Data to E-mail Address Fools Gold Starting Out 4 Dec 23rd, 2007 14:16
About sending form-data to an email address a.jenery Web Page Design 4 Mar 3rd, 2006 12:17
CGI that lists and sorts form data?? pelachrum Web Page Design 3 Aug 29th, 2005 07:51
inserting data to mysql db Tim356 PHP Forum 1 May 6th, 2005 04:20


All times are GMT. The time now is 00:49.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43