Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using mysql to connect to database and send to thank you page.

    Hello I have a problem with the mysql and PHP coding. The problem is when a person types the information and click on the submit button on the web site. The submit button should take you to a thank you page. Instead the submit button returns you to the same page. The address of the problem page is http://www.honorpac.org/rsvp/rsvp.php The designer used the edit form action with htmlentities and in the mysql select db coding it has a insert GoTo=”thankyou.html”;. How can I have the submit button take you to the thank you page?

    Actual Coding from the web site:

    <?php require_once('../Connections/contributions.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"] == "contributions")) {
    $insertSQL = sprintf("INSERT INTO contributions (name, address, city, `state`, zip, occupation, employer, contribution, recurring_amount, guests, member, cc_name, cc_exp_mon, cc_exp_yr, cc_no, cc_type, cc_addy, cc_city, cc_state, cc_zip, phone, fax, cell, email, comments, date_submitted, reffering_page) 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, %s)",
    GetSQLValueString($_POST['name'], "text"),
    GetSQLValueString($_POST['address'], "text"),
    GetSQLValueString($_POST['city'], "text"),
    GetSQLValueString($_POST['state'], "text"),
    GetSQLValueString($_POST['zip'], "text"),
    GetSQLValueString($_POST['occupation'], "text"),
    GetSQLValueString($_POST['employer'], "text"),
    GetSQLValueString($_POST['contribution'], "text"),
    GetSQLValueString($_POST['recurring_amount'], "text"),
    GetSQLValueString($_POST['guests'], "text"),
    GetSQLValueString($_POST['member'], "text"),
    GetSQLValueString($_POST['cc_name'], "text"),
    GetSQLValueString($_POST['cc_exp_mon'], "text"),
    GetSQLValueString($_POST['cc_exp_yr'], "text"),
    GetSQLValueString($_POST['cc_no'], "text"),
    GetSQLValueString($_POST['cc_type'], "text"),
    GetSQLValueString($_POST['cc_addy'], "text"),
    GetSQLValueString($_POST['cc_city'], "text"),
    GetSQLValueString($_POST['cc_state'], "text"),
    GetSQLValueString($_POST['cc_zip'], "text"),
    GetSQLValueString($_POST['phone'], "text"),
    GetSQLValueString($_POST['fax'], "text"),
    GetSQLValueString($_POST['cell'], "text"),
    GetSQLValueString($_POST['email'], "text"),
    GetSQLValueString($_POST['comments'], "text"),
    GetSQLValueString($_POST['date_submitted'], "date"),
    GetSQLValueString($_POST['reffering_page'], "text"));

    mysql_select_db($database_contributions, $contributions);
    $Result1 = mysql_query($insertSQL, $contributions) or die(mysql_error());
    $insertGoTo ="thankyou.html";}

    <!-- End Left Rail--><!-- Content Section -->
    <td align="left" valign="top" bgcolor="#fcf0c7"><!-- InstanceBeginEditable name="Region" -->
    <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="contributions" id="contributions" onsubmit="return checkFields();">
    <input name="reffering_page" type="hidden" id="reffering_page" value="Yacht Cruise" /> <input type="hidden" name="date_submitted" value="<?php echo date('Y-m-d H:i:s') ?>" />
    <table width="675" border="0" cellspacing="0" cellpadding="3">
    <tr>

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts

    Question

    hi,

    u need to add the following line at...

    Code:
    $Result1 = mysql_query($insertSQL, $contributions) or die(mysql_error());
    $insertGoTo ="thankyou.html";
    //new code must go here
    header("Location: $insertGoTo");
    and as long as no error are produced your page will navigate to the thankyou.html page.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •