Jump to content

dynamically assign go to page (after inserting rec


Recommended Posts

i've tried inserting php code into the "Go to after inserting" page of a "Insert Record" form. dreamweaver seems to only like actual page entries like test.php. if i try and put a url paramater that equals a page link the form breaks and dreamweaver erases half the code automatically. does anyone know of a way to create a form in dreamweaver but assign the page it goes to after submitting to a "dynamic" entry.

 

 

I have a same problem by using server behavior in Dreamweaver MX for inserting a user record. Don't know why I've got a error:Parse error: parse error, unexpected ';' in /home/symphon1/public_html/add_user_record.php on line 26

 

Here is the codes:

 

<?php require_once('../Connections/filmmaker.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 = $HTTP_SERVER_VARS['PHP_SELF'];

if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {

$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];

}

 

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "userform")) {

$insertSQL = sprintf("INSERT INTO filmmakers (`first`, `last`, address, city, `state`, zip, country, bio, email) VALUES (firstName, lastName, address, city, state, country, bio, email)",

GetSQLValueString($HTTP_POST_VARS['firstName'], "text"),

GetSQLValueString($HTTP_POST_VARS['lastName'], "text"),

GetSQLValueString($HTTP_POST_VARS['address'], "text"),

GetSQLValueString($HTTP_POST_VARS['city'], "text"),

GetSQLValueString($HTTP_POST_VARS['state'], "text"),

GetSQLValueString($HTTP_POST_VARS['zip'], "int"),

GetSQLValueString($HTTP_POST_VARS['country'], "text"),

GetSQLValueString($HTTP_POST_VARS['bio'], "text"),

GetSQLValueString($HTTP_POST_VARS['email'], "text"));

 

mysql_select_db($database_filmmaker, $filmmaker);

$Result1 = mysql_query($insertSQL, $filmmaker) or die(mysql_error());

 

$insertGoTo = "/public_html/user_record_details.php?email=".$HTTP_POST_VAR['email']."";

if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {

$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";

$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];

}

header(sprintf("Location: %s", $insertGoTo));

}

?>

<?php echo "<?xml version=\"1.0\" encoding=\"big5\"?".">"; ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>add_user_record</title>

<meta http-equiv="Content-Type" content="text/html; charset=big5" />

<script language="JavaScript" type="text/JavaScript">

<!--

function MM_displayStatusMsg(msgStr) { //v1.0

status=msgStr;

document.MM_returnValue = true;

}

 

function MM_findObj(n, d) { //v4.01

var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];

for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);

if(!x && d.getElementById) x=d.getElementById(n); return x;

}

 

function MM_validateForm() { //v4.0

var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;

for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args);

if (val) { nm=val.name; if ((val=val.value)!="") {

if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');

if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';

} else if (test!='R') { num = parseFloat(val);

if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';

if (test.indexOf('inRange') != -1) { p=test.indexOf(':');

min=test.substring(8,p); max=test.substring(p+1);

if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';

} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }

} if (errors) alert('The following error(s) occurred:\n'+errors);

document.MM_returnValue = (errors == '');

}

//-->

</script>

</head>

 

<body>

<center>

<p>Add a User Record</p>

<p>Fill in the form below, with your name and address detail,<br />

to add your record to our system</p>

<form name="userform" id="userform" method="POST" action="<?php echo $editFormAction; ?>">

<table width="60%" border="0" cellpadding="2" cellspacing="2">

<tr>

<td width="34%" align="right">First Name:</td>

<td width="66%"> <input name="firstName" type="text" id="firstName" onFocus="MM_displayStatusMsg('Please enter your First Name');return document.MM_returnValue" maxlength="30" /></td>

</tr>

<tr>

<td align="right">Last Name:</td>

<td> <input name="lastName" type="text" id="lastName" onFocus="MM_displayStatusMsg('Please enter your Last Name');return document.MM_returnValue" maxlength="30" /></td>

</tr>

<tr>

<td align="right">Address 1:</td>

<td> <input name="address" type="text" id="address" onFocus="MM_displayStatusMsg('Please enter address');return document.MM_returnValue" maxlength="100" /></td>

</tr>

<tr>

<td align="right">Address 2:</td>

<td> <input name="address" type="text" id="address" onFocus="MM_displayStatusMsg('Please enter address');return document.MM_returnValue" maxlength="100" /></td>

</tr>

<tr>

<td align="right">City:</td>

<td> <input name="city" type="text" id="city" onFocus="MM_displayStatusMsg('Please enter City');return document.MM_returnValue" maxlength="100" /></td>

</tr>

<tr>

<td align="right">State:</td>

<td> <input name="state" type="text" id="state" onBlur="MM_displayStatusMsg('Please enter State');return document.MM_returnValue" maxlength="100" /></td>

</tr>

<tr>

<td align="right">Zip:</td>

<td> <input name="zip" type="text" id="zip" onFocus="MM_displayStatusMsg('Please enter Zip');return document.MM_returnValue" maxlength="20" /></td>

</tr>

<tr>

<td align="right">Country:</td>

<td> <select name="country" id="country" onFocus="MM_displayStatusMsg('Please select a Country');return document.MM_returnValue">

 

<option value="USA">USA</option>

<option value="GERMANY">GERMANY</option>

<option value="SPAIN">SPAIN</option>

<option value="FRANCE">FRANCE</option>

<option value="ENGLAND">ENGLAND</option>

</select></td>

</tr>

<tr>

<td align="right">Bio:</td>

<td> <textarea name="bio" rows="10" id="bio" onFocus="MM_displayStatusMsg('Please input your bio');return document.MM_returnValue"></text></td>

</tr>

<tr>

<td align="right">Email:</td>

<td> <input name="email" type="text" id="email" onBlur="MM_displayStatusMsg('Please enter email address');return document.MM_returnValue" maxlength="100" /></td>

</tr>

<tr>

<td align="right">Thumb:</td>

<td>&nbsp;</td>

</tr>

<tr>

<td align="right">&nbsp;</td>

<td>

<input name="addmyrecord" type="submit" onClick="MM_validateForm('firstName','','R','lastName','','R','0','','R','1','','R','city','','R','state','','R','zip','','R','email','','RisEmail','textarea','','R');return document.MM_returnValue" value="Add My Record" /></td>

</tr>

<tr>

<td>&nbsp;</td>

<td>&nbsp;</td>

</tr>

</table>

<input type="hidden" name="MM_insert" value="userform">

</form>

<p>&nbsp;</p>

</center>

</body>

</html>

 

  • 1 month later...

Reply to begeiste:

 

In your switch statement, there is one case that you did not 'break'. That is the only reason for your problem that I could find, however I'm only a beginner.

Fixed switch statment:

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break; 
case "long":
break;
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;
}

 

Edit: Just a question, why is require_once('../Connections/filmmaker.php'); in a different PHP block? Just wondering.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.