Hi team,
Thanks for the view..
So here is my question...

Here's what I am trying to do... I have a form that people fill in to send an email to selected people. They fill in the form and it now goes to a database to hold it until approved by the admin (me). So I thought that if I could autofill a new form with thier info I would send it for them. But when I tried, the submit button to a separate php was giving errors...

I pieced meal a few codes which I know is messing it up
1 to put a prev and next record link on page
2 was originally for autofilling fields

Here is the code:

<?php

// Connect to server and select database. 

session_start(); 
session_unregister("data"); 
if(!session_is_registered("data")) { 
    session_register("data"); 
 $db = mysql_connect("$hostname", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB"); 
    $result = mysql_query("SELECT * from $tbl_name"); 
    while($row = mysql_fetch_array($result)) { 
        $data[] = $row; 
        } 
    } 

$offset = ($offset) ? $offset : 0; 

?> 
    <link rel="stylesheet" href="/css/style.css" type="text/css">
<form name="tellanofficial" action="insertbne3.php" method="post" onSubmit="return checkfields()">&nbsp;
<div align="center">
<center>
<table border="0" cellpadding="10" cellspacing="0">
<tr>
<td>
<table border="0" cellSpacing="0" cellPadding="0" width="100%">
	<tr>
		<td colSpan="2"><span class="xc_labeltext"><strong><font size="2" face>
		Your Contact Information:</font></strong></span></td>
	</tr>
	<tr>
		<td>
		<style type="text/css">

<!-- 
.inputtext { width: 354px; height: 144px; 
white-space: -moz-pre-wrap !important;  /* Mozilla, since 1999 */ 
 white-space: -pre-wrap;      /* Opera 4-6 */ 
 white-space: -o-pre-wrap;    /* Opera 7 */ 
 white-space: pre-wrap;       /* css-3 */ 
 word-wrap: break-word;       /* Internet Explorer 5.5+ */ 
} 



table.xform_table td {
    padding-bottom: 2px
}


--> 


</style>
		<table class="xform_table" border="0" cellSpacing="0" cellPadding="0" width="100%">
			<tr>
				<td style="padding-bottom: 2px"><font face size="2">
				<br>
				</font><input style="WIDTH: 40px" class="xc_maintext" maxLength="50" size="29" name="prefixprospect" value="<?=$data[$offset]['prefixprospect']?>">

				<span id="x_id__prefix" class="xc_datalabel"><font face size="2"><strong><font color="#333333"> 
				Prefix </font></strong>
				<span class="xc_maintext"></span></font><span class="xc_maintext"></span><font face size="2"><strong><font color="#333333">
				</font></strong>
				</font>
				</span></td>
			</tr>
			<tr>
				<td style="padding-bottom: 2px">
				<table border="0" cellSpacing="0" cellPadding="0">
					<tr>
						<td style="padding-bottom: 2px">
						<span id="x_id__first" class="xc_datalabel"><strong>
						<font color="#333333" size="2" face>First </font>
						</strong></span><font face size="2" color="#cc0000">
						<span class="cwsubredbold">*</span><br>
						</font>
						<input style="WIDTH: 228px" class="xc_maintext" maxLength="50" size="29" name="firstprospect" AUTOCOMPLETE="On" value="<?=$data[$offset]['firstprospect']?>"></td>
						<td style="padding-bottom: 2px">
						<font color="#cc0000" size="2" face>
						<img border="0" alt="" src="sec_remove_eng.png" width="10" height="1"></font></td>
						<td style="padding-bottom: 2px">
						<span id="x_id__last" class="xc_datalabel"><strong>
						<font color="#333333" size="2" face>Last </font>
						</strong></span><font face size="2" color="#cc0000">
						<span class="cwsubredbold">*</span><br>
						</font>
						<input style="WIDTH: 228px" class="xc_maintext" maxLength="50" size="29" name="lastprospect" AUTOCOMPLETE="On" value="<?=$data[$offset]['lastprospect']?>"></td>
					</tr>
				</table>
				</td>
			</tr>
			<tr>
				<td style="padding-bottom: 2px">
				<span id="x_id__email" class="xc_datalabel"><strong>
				<font color="#333333" size="2" face>Email </font></strong>
				</span><font face size="2" color="#cc0000">
				<span class="cwsubredbold">*</span><br>
				</font>
				<input style="WIDTH: 468px" class="xc_maintext" maxLength="71" size="60" name="email0" AUTOCOMPLETE="On" value="<?=$data[$offset]['email0']?>"></td>
			</tr>
			<tr>
				<td style="padding-bottom: 2px">
				<span id="x_id__address" class="xc_datalabel"><strong>
				<font color="#333333" size="2" face>Address </font></strong>
				</span><font face size="2" color="#cc0000">
				<span class="cwsubredbold">*</span><br>
				</font>
				<input style="WIDTH: 468px" class="xc_maintext" maxLength="75" size="60" name="addressprospect" AUTOCOMPLETE="On" value="<?=$data[$offset]['addressprospect']?>"></td>
			</tr>
			<tr>
				<td style="padding-bottom: 2px">
				<span id="x_id__city" class="xc_datalabel"><strong>
				<font color="#333333" size="2" face>City </font></strong></span>
				<font face size="2" color="#cc0000"><span class="cwsubredbold">*</span><br>
				</font>
				<input style="WIDTH: 125px" class="xc_maintext" maxLength="50" size="60" name="cityprospect" AUTOCOMPLETE="On" value="<?=$data[$offset]['cityprospect']?>"></td>
							<td style="padding-bottom: 2px">
				<table border="0" cellSpacing="0" cellPadding="0">
					<tr>
						<td style="padding-bottom: 2px"><font size="2">
						<span id="x_id__state" class="xc_datalabel"><strong>
						<font color="#333333" face>State </font></strong></span>
						<font face color="#cc0000"><span class="cwsubredbold">*</span><br>
						</font></font>
						<input style="WIDTH: 30px" class="xc_maintext" maxLength="50" size="29" name="stateprospect" value="<?=$data[$offset]['stateprospect']?>">
						</td>
						
						<td style="padding-bottom: 2px">
						<span id="x_id__azip" class="xc_datalabel"><strong>
						<font color="#333333">ZIP </font></strong></span>
						<span class="cwsubredbold">*</span><br>
						<input class="xc_maintext" maxLength="8" size="8" name="azipprospect" AUTOCOMPLETE="On" value="<?=$data[$offset]['azipprospect']?>"></td>
						
						<td style="padding-bottom: 2px"><br>
&nbsp;</td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
	</tr>
</table>
<p align="left">These are the people that will be receiving this email 
to be sent to:</td>
</tr>
<tr>
<td>

  <div align="left">email 1    <input name="fmail1" type="text"maxlength="30"size=25" value="<?=$data[$offset]['fmail1']?>"/>  
</div></tr>
<tr>
<td>
  <div align="left">email 2    <input name="fmail2" type="text"maxlength="30"size=25" value="<?=$data[$offset]['fmail2']?>"/></div></td>
</tr>
<tr>
<td>
  <div align="left">email 3
    <input name="fmail3" type="text"maxlength="30"size=25" value="<?=$data[$offset]['fmail3']?>"/> </div></td>
</tr>
<tr>
<td>
  <div align="left">Email 4    <input name="fmail4" type="text"maxlength="30"size=25" value="<?=$data[$offset]['fmail4']?>"/> </div></td>
</tr>
<tr>


<td>
<p align="center">
The following email will be sent on your behalf and you may change the message 
to be more personalized if you wish.&nbsp; Your sender information will be added 
to the top of the email.<p align="center">
<textarea rows="12" name="prospectmessage" cols="84">
<?=$data[$offset]['prospectmessage']?>
</textarea>

<p align="center"><br>
  <input onClick="validate();" type="button" value="Click once to send">
  <input type=hidden name=refurl value="<? print $refurl;?>"> 
</td>
</tr>
</table>
</center>
</div>
</form>

<? 
if($offset > 0) { 
    ?> 
    <a href="<?=$PHP_SELF?>?offset=<?=($offset - 1)?>">prev record</a> 
    <? 
    } 
if($offset < count($data)) { 
    ?> 
    <a href="<?=$PHP_SELF?>?offset=<?=($offset + 1)?>">next record</a> 
    <? 
    } 
?>

I would appreciate any help I could get..
Thanks...

Recommended Answers

All 5 Replies

Could you be a little more specific?

"But when I tried, the submit button to a separate php was giving errors..."

Does this mean the page that you're submitting to is giving error? If so, what are they and can you post the code?

sorry..

When I hit submit I get an error with in the same page. I get an object expected on line 166 Char 1
code 0

I don't see any JavaScript or any links to JavaScript on the page, yet you have two validations that I can see within the same form.

The first will never be called because you're using a button instead of a submit button. The second doesn't submit anything unless the validate() function submits if the content is correct.

<form name="tellanofficial" action="insertbne3.php" method="post" onSubmit="return checkfields()">
<input onClick="validate();" type="button" value="Click once to send">

Also...

value="<?=$data[$offset]['fmail3']?>"

You're not printing out the variables.

value="<? echo $data[$offset]['fmail3']?>"

PHP see's what you had as =$data[$offset] which doesn't make sense. It can't interact with the HTML, it can only print text.

thanks..
yes the javascript was left overs from the original form that I missed. I had validation on submit button...

Don't forget to close out the post if your question is answered. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.