Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TOUGH QUESTION-NEED FORM EXPERT

Status
Not open for further replies.

RPGguy

Programmer
Jul 27, 2001
73
US
I suspect this won't be easy. I have a form to enter customers with 10 or so input fields. The form is described as:
<form method=POST action=&quot;updCust.html&quot;>

and the update button as:
<td><input type=&quot;submit&quot; value=&quot;Update Customer&quot; name=&quot;B1&quot;></td>

This is great in that it automatically passes the fields to my update script. The update script looks like this:
<HTML>
<?php
$query4 = &quot;UPDATE tblCust SET Cust='$cust',Name='$name',Contact='$contact',Address1='$address1',Address2='$address2',City='$city',State='$state',Zip='$zip',Type='$type',Phone='$phone',Fax='$fax',Notes='$notes' where Cust = '$cust'&quot;;

$link = mysql_connect(&quot;localhost&quot;, &quot;***&quot;, &quot;*****&quot;);
mysql_select_db(&quot;Liebert&quot;);

$result = mysql_query($query4);


<table border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;3&quot; style=&quot;border-collapse: collapse&quot; width=&quot;325&quot; id=&quot;AutoNumber1&quot; height=&quot;92&quot; bgcolor=&quot;#FFFFFF&quot; bordercolor=&quot;#FFFFFF&quot; align=&quot;left&quot;>

<tr>
<td width=&quot;509&quot; height=&quot;7&quot; valign=&quot;baseline&quot; align=&quot;left&quot; bordercolor=&quot;#FFFFFF&quot; bgcolor=&quot;#FFFFFF&quot; rowspan=&quot;2&quot;>
<p align=&quot;center&quot;>Record successfully updated!</p>
<p align=&quot;center&quot;>
<input type=&quot;button&quot; value=&quot;Return&quot; name=&quot;bReturn&quot; width=&quot;30&quot; onClick=&quot;self.history.back();&quot;>
</td>
</tr>
</table>
?>
</BODY>
</HTML>

Everything works fine except that I would like my update message to appear in a pop up window. I've tried the javascript command to open a pop up window but that stops my update script from receiving the fields as parameters.

If this can't be done can someone suggest an alternate way of accomplishing it. Prehaps I can move the pop up to a new script executed by the update script. I just want to be sure when the user clicks the 'Back' button they return all the way back to the original form.

Thanks in advance.

Scott
 
since you are using php, place the separate elements into functions and then you have the ability to call functions as you need them.

Code:
if (!$_POST['submit']){

    //the submit button not pressed so show the data form
    show_form();

}else{

    //process the data and run the update
    process_form();

}
function show_form()
{
//html [and php] code to show the form as required

}
function process_form()
{

//php code to accept,[v]verfiy[/b] and update the db


if ($result){  //db query works - does what its supposed to
    show_confirmation();  //call confirmation function
}else{
    show_failure();       //call failure function
}

}
function confirmation()
{
//html code to show a page/pop up that confirms entry success - personally I prefer a full page as you can provide link to show the form again (&quot;update another customer&quot;) or pass the user to somewhere else
}
function show_failure()
{
//html code to show a page/pop up that confirms entry success - personally I prefer a full page as you can provide link to show the form again with the user data filled out [b]to be edited as needed[/b]-->uses the value attribute of the element tag to provide values filled in
}

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
If I understand the question correctly, you want the form to submit to a popup window. This can be done by first using the javascript open function to open a blank window, sized to you liking, and linking to &quot;about:blank&quot;. Then in the submit tag put in this:

onSubmit=&quot;popWindow();&quot; target=&quot;window_name&quot;

window_name is then name you gave the window in the javascript function.

The question then remains, what do you want to do with the original form page? Because it will still have the information stored in the form.

 
With the current code in the original form:

The form is described as:
<form method=POST action=&quot;updCust.html&quot;>

and the update button as:
<td><input type=&quot;submit&quot; value=&quot;Update Customer&quot; name=&quot;B1&quot;></td>

the submit passes all my input fields as parameters directly into updCust.html which works great.

I want to preserve this functionality but with updCust.html giving me a message in a pop up window. I've tried using the 'popupwindow()' to use updCust.html and lost all my input values.

Do you think your method will work this way?
 
Well the problem really is that you have no way to notify the user if something goes wrong...you are simply going to open a pop-up that gives the user a message.

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
I agree the error handling has to be addressed. I'm pretty new to all of this (hence the RPG moniker) and I'm trying to get a feel for the functionality.

I can empathize with being laid off. The last 2 years have been shaky for me too.
 
One note...the action=updateCust.html is never going to work. HTML pages can not interact with the server/db/filesystem in any way shape or form...you are gonna need to direct the page to .php, .asp. etc so that the server know there is a scripting language engine to invoke and make the whole sucker go

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
One other note, many people now employ pop-up blockers, that may or may not affect the functionality of the site

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top