HTML submit button within PHP

Hello,
The first section of code below returns a message that says "The topic 'x' has not been added." if a user enters a topic that is not in my database.  I would like to give the user the option to add "x" to the database by clicking on an HTML submit button.  So I guess my problem is that I don't know how to add an HTML submit button within PHP that would post $name=$find to tprocess.php and then trigger the code in tprocess.php.  How do I do that?
Thanks,
John
$anymatches=mysql_num_rows($result);
if ($anymatches == 0)
print "<p class=\"topic2\">The topic \"$find\" has not been added.</p>\n";
print "<p class=\"topic2\">Add the topic \"$find\".</p>\n";
<form action="tprocess.php" method="post">;
$name=$find;
<input type="submit" value="Submit">";
</form>;
Below is what I have on tprocess.php.  It is code that adds a topic to my database:
if (isset($_POST['name']) && !empty($_POST['name'])) {
mysql_connect("mysqlv10", "username", "password") or
die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$table = mysql_real_escape_string($_POST['name']);
$query = "CREATE TABLE `$table` (id INT(11) NOT NULL auto_increment, site VARCHAR(150) NOT NULL, votes_up BIGINT(9) NOT NULL, votes_down BIGINT(9) NOT NULL, PRIMARY KEY(id), UNIQUE (site))";
$result = mysql_query($query) or die(mysql_error());

Just add it to a hidden field in the form. Sorry I don't know php, but in ASP you would use something like this:
<% If  MyTestCondition = 1 Then %>
<form action="tprocess.php" method="post">
<input name="Find type="hidden" id="Find" value=<%=Find%> >
<input type="submit" value="Submit">"
</form>
<%End If%>
So I'm sure you could do something similar with PHP.
Now, unrelated to your question, I am curious about this:
$query = "CREATE TABLE `$table` (id INT(11) NOT NULL auto_increment, site VARCHAR(150) NOT NULL, votes_up BIGINT(9) NOT NULL, votes_down BIGINT(9) NOT NULL, PRIMARY KEY(id), UNIQUE (site))";
Are you creating new tables for each new topic and the bigger question, why    ??

Similar Messages

  • Calling a method with a html Submit button

    hi guys,
    is it possible to call a method from a JSP file using a HTML submit button. I know i can call another website easily doing it this way, is there a similar way available to call a method once the button is clicked?
    FYI
    The method is in a bean file named jdbc. The methods name is getUsername.
    Nice one.
    <form action = <%jdbc.getUsername()%> <input type="submit" value="Submit">

    Dear friend,
    you mentioned that u need to call a method when submit button is clicked. Is the method dynamically created. If not so, then you can include the method on the submit button html file itself.
    Regards,
    Rengaraj.R

  • Submit button within Interactive adobe form

    Hi,
        We have developed an Interactive adobe form and inserted a submit button within it We have installed ACI also.We tried putting the submit button both within the adobe form body and also within the webdynpro java view. In both the cases pressing the submit button does not result in any action. Please advise on what we are missing. We checked the forums for similar issues and found out that we are abiding by most of it.
    thanks
    anantharam

    Hi Anantharam,
    Please create and action in your view and attach it to your Interactive form UI element's onSubmit event. By doing this, whenecver you press the Submit button in the form, this action will be invoked. You can place any methots/code that you want to execute on click of submit button.
    If you are using the button outside the form, then you try printing one of the values that you filled in the form which is binded to context. This way you can test.
    If you are using WDP activex UI element s in the form then you need to have ACF installed on the machine and also ensure that the displayMode property of Interactive form is set to ActiveX.
    Hope this helps!!
    Regards,
    Arafat

  • Htmls:submit buttons and links in struts

    Hello,
    I am developing a struts web application. In the course of that I have two questions:
    How can I define an image to display for a html:submit button instead the traditional visualization of the html:submit button?
    The same for links - How can I define an image for a link?
    thanks in advance
    Kind Regards
    pat

    How can I define an image to display for a
    html:submit button instead the traditional
    visualization of the html:submit button?
    The same for links - How can I define an image for a
    link?
    <html:image>

  • HTML submit button in a folio won't generate an email.

    I have an HTML page with a form and submit button that creates an email with the results of the form.
    In Safari on the iPad the form and submit button work, but when the HTML link is viewed in a folio page the submit button will not work, even though all the fields are fillable and working. The code is following.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
              <title>mailto Example</title></head>
    <body>
    <form action="mailto:[email protected]" method="post" enctype="text/plain" >
      FirstName:
      <input type="text" name="FirstName">
    Email:<input type="text" name="Email">
    <input type="submit" name="submit" value="Submit">
    </form>
    </body>
    </html>

    First, the page is down, I just get a generic page.  Second you may need to reach out to your web host.  I see that you are using hosting from Intuit.  Being that they have a proprietary setup, some custom scripts may not work.
    Third, once that is confirmed, if you are making this script I would recommend changing the $_REQUEST text in the sendmail to $_POST.  $_REQUEST means that your form can get spammed because they can pass the data via GET or POST.  The $_POST is just the first step to ensure the data came from your form.

  • Signature with Submit Button

    Hi,
    I was wondering if it was possible to include an EchoSign signature as a replacement for the submit button within my survey.
    Thanks,
    Alex

    Hi,
    This is not something we currently support but you can add or vote on feature ideas:
    http://forums.adobe.com/community/formscentral?view=idea
    If you need to add a new idea click "Create an idea" under "Actions" in the top right.
    Thanks

  • SQL Insert with submit button

    Hey i was just wondering if any of yous knew how to get a html submit button to insert new information into a database table??
    i.e. Insert into Photo(PhooName) Values("hello")
    Im using jsp and htm. And im not using beans!!

    Hey i was just wondering if any of yous knew how to get a html submit button to insert new information into a database table??
    i.e. Insert into Photo(PhooName) Values("hello")
    Im using jsp and htm. And im not using beans!!

  • Struts submit button focus

    Hello
    I have following prob:
    a form with three buttons
    a submit (normal html-button)
    a cancel (struts html:cancel button)
    and a reset (struts html:reset button)
    since I need javascript to run before submitting
    and after the result of the javascript function deciding if submiting or not I used a submit html-button (I cannot stop the struts html:submit button from submitting even if a put a javascript onClick after the javascript function comes the submition (is there a way to stop it?)).
    For the other two buttons the struts html tags.
    Now if the user press enter (regardless where the focus is in the form) the cancel action is being activated (the form cancelled)
    if I use javascript to put the focus on submit, as soon as the user click on a text field (or any other form component) the "button group focus" moves to the cancel button!
    (regardless where was the focus is in the form)
    How can I get the "enter key focus" staying on submit?
    I already tried the struts <html:form ... focus="submitButton"> and it works at page-load-time BUT as soon as the user click on a text field (or any other form component) the "button group focus" moves to the cancel button ! ! !
    Is there a kind of "enter key" focus which works independent from the fields focus?
    Thanks!

    The regular way to cancel a javascript action is to return false from the onclick event.
    I don't see any reason it wouldn't work with html:submit
    ie
    function checkSubmit(){
      if ( checkIsOk){
        return true;
      alert("You got it wrong moron!");
      return false;
    <input type="submit" onclick="return checkSubmit()">

  • Submit button from Adobe form doesn't trigger action???

    Hi all,
    the submit button within Adobe form doesn't trigger any action that i wrote. it happens to my machine, but it doesn't happen on some of my colleague's machines.
    i am using Adobe reader 8, when the first time i use IE to display the app, it prompts me to install some kind of activeX plug in, and after it installed, it told me that some setting is not correct, and it mentioned about adobe reader 6 or 7.
    will downgrade to 6 or 7 solve this problem? is there any other walkaround for it?
    thank you!

    If you are on Netweaver 2004s SP9 or higher, you could change the displayType property of InteractiveForm UI element to "Web Dynpro Native" and use the submit button from "Native" tab.
    If you are any other lower version, you dont have a choice but to use "activeX" which requires Active Component Framework (ACF) to communicate with server. You need to use button from "Web Dynpro ActiveX" tab. You need to install the right version of ACF (SAP Note 766191). Better if you use Adobe Reader 8.1.2.
    Thanks
    Ram

  • Php sql image editor - help with submit buttons!

    Hi,
    I have recently setup a website for my real-estate company, with a makeshift CMS behind it for my staff to use when updating properties.
    I have a slideshow on my site for each property, which is populated through sql blobs (I know alot of people dont think this is the best method but I have managed to get it working so I am happy with it!).
    Assuming the database has 4 fields - id, image1, image2, and image3 - I have managed to build separate pages to edit image1, image2 or image3 based on the id as per:
    <?php
    $db_host = 'xx'; 
    $db_user = 'xx';
    $db_pwd = 'xx';
    $database = 'xx';
    $id=$_GET['id'];
    ?>
    <?php
    if (!mysql_connect($db_host, $db_user, $db_pwd))
        die("Can't connect to database");
    if (!mysql_select_db($database))
        die("Can't select database");  
    function sql_safe($s)
        if (get_magic_quotes_gpc())
            $s = stripslashes($s);
        return mysql_real_escape_string($s);
    if ($_SERVER['REQUEST_METHOD'] == 'POST')
              if (!isset($msg))
                    $data = file_get_contents($_FILES['photo']['tmp_name']);
                    $data = mysql_real_escape_string($data);
                    mysql_query("UPDATE slideshow SET image1='$data' WHERE id='$id'");
                    $msg = 'Success: image uploaded';
            ?>
    <html><head>
    <title>Slideshow Images</title>
    <meta http-equiv="content-type" content="text/plain; charset=utf-8" />
    </head>
    <body>
    <table width="974" border="1">
        <tr>
          <td width="158"><img src="ss/show_slideshow1.php?id=<?php echo $id ?>" alt="Image1"></td>
          <td><?php
    if (isset($msg))
    ?><?=$msg?><?php
    ?>
    </td>
    <td width="664"><form action="<?=$PHP_SELF?>" method="POST" enctype="multipart/form-data">
    <input type="file" name="photo" id="photo">
    <input type="submit" value="upload">
    </form></td></tr></table>
    The above code will display image1, and let me edit it using a simple submit button.
    What I am trying to do though, it to get all the images for the property where id ='$id' on one page with respective edit buttons. I can display them all on the same page easily, but cannot seem to crack the UPDATE form for each image.
    Appreciate any advice or help in solving this!!
    Thanks
    Jack

    Your code has been been copied to the end of the style rules.. not the rest of the html.
    It would actually be better if you could provide a link to the live site, it's always much better for troubleshooting purposes to see the live page.
    Can you do that?

  • Which form would work best with a Filemaker database? PDF or HTML? and can we use a submit button to do this?

    We are looking at developing work forms for a project that will use a submit button to send the data from the form to a Filemaker database. My question is can this be done with a PDF or do we need to convert it to a HTML form?

    The architecture is not submit form - database, not exactly. It's submit form - web app - database. The crucial thing is the web app, perhaps one of CGI/PHP/ASP/others... FileMaker Pro seems a slightly unusual choice for a web back end, but there is a FileMaker Pro Server product. (Regular FileMaker is out of the question).
    So, you can have a web app which takes HTML format submits and updates a database. What about PDF?
    * PDF can submit the same format as HTML, so the same backend can work
    * PDF can submit other formats, FDF or XFDF. The web script could handle these.
    Frankly, if HTML is an option I'd go with HTML. There are many important compatibility issues with PDF forms, since so many browsers now do not use Adobe technology, and have their own. In these alternatives, form support goes from nonexistent to flaky, via badly broken.

  • Submit button in inserted HTML is not correctly shows

    Submit button in inserted HTML is not correctly shows.
    <input type="submit" name="submit" value="Submit">
    Button doesn't have a round gradient background like in real HTML.  
    Looks like Muse translated it not correctly. Muse doesn't use inserted code directly to the browser.
    The ??? is how to see a real html appearance?

    Dear All
    I feel adobelance is giving us a pretty good answer.
    I tried code in Dreamweaver and got:
    And in Muse I got:
    I did have to change the border from outset to solid grey (to give it the colour) - the main difference seems to be the font.  It was close enough for me, though.
    I am not a Dreamweaver developer and this is the first code I have run in Dreamweaver (successfully, anyway).
    Muse allows Designers to sketch web sites and as such is good - but it is not Dreamweaver.  I admit I subscribe to Creative Cloud - so I can use Dreamweaver or Muse and am using the latest version but I am a fan of Muse so far. 
    My HTML in Muse is
    <form>
    <form method="post" action="senddata.php">
    <label for="lastname" style="color:black; background:light grey">Last Name:</label>
    <input type="password" id="lastname" name="lastname">
    <input type="submit" value=" Submit Form! " style="border:2px solid grey; color:black; background:light grey">
    </form>
    I do hope this assists you all.
    Kind regards

  • HTML Form Submit Button to call a procedure

    hi! been looking high and low across all forums and it seems there are specific users like myself having problems with submit button and pl/sql procedures. Hope someone can clarify on this.
    Scenario: created a html/dynamic page with a submit button(no java scripts, just plain <form action="schema.procedure" method="post"> etc) to pass values into a procedure to update database. In my case, i've hard coded the values in the procedure for testing purpose(thus my procedure don't receive any in parameters).
    Problem:
    Clicking on Submit button will result a page not found error.
    Solution read so far:
    Ensure that at least the Public has been granted Execute Access on that procedure, which i find funny cos I am logged in as the adminstrator having all the rights, heck, i even created the schemas, procedures and tables.
    Result for me:
    Page not found displayed, but when I highlight the url on that page (which is the complete address)and press Enter, the procedure went through and display the message in my procedure?!
    But if I clik on a link (pointing to the same procedure), the procedure went through immediately.
    I have tried:
    a) clearing the browser cache
    b) deleting archive versions of the page
    c) entering the whole address
    d) recreate the html page using pl/sql
    but still the same problem.
    Any advise on this? Is this a bug? how to go around this?
    Rgds.

    Hi,
    I did the following :
    1) created a procedure called test1 in schema portal30
    create or replace procedure test1
    as
    begin
    htp.p('Hi there');
    end;
    2) granted it to public
    grant execute on test1 to public;
    3)created a dynamic page like this:
    <HTML>
    <HEAD>
    <TITLE>Example</TITLE>
    </HEAD>
    <BODY>
    <form action='portal30.test1'>
    <input type="Submit" value="click me">
    </Form>
    <H1>Example of A Dynamic Page</H1>
    <ORACLE>select * from PORTAL30_DEMO.emp where deptno = :department</ORACLE>
    </BODY>
    </HTML>
    4) ran the dynamic page ,works fine
    Thanks,
    Anu

  • How to use many submit buttons in an one html form

    I'm doing a simple program to insert, edit, delete data from a web page to an database
    but the problem is that in an html form , you are allowed to put only 1 submit button.
    I heard that you can take the action of many buttons, for a one form using java script
    if anyone have a better idea or else have this simple java script, please help me
    Thank you very much

    Give the buttons an unique name.
    In the servlet just check if the button is pressed or not by determining if HttpServletRequest#getParameter() doesn't return null for the button name.There are a couple of "gotchas" when using this technique of dispatching with certain html controls. Most of them browser related.
    If you are using <input type="image" name="myButton"> as a submit button, be aware that Internet Explorer will submit the parameters "myButton.x" and "myButton.y" giving the x,y co-ordinates of where you clicked on the button. And won't submit any other value. So calling request.getParameter("myButton") would return null. You have to test for request.getParameter("myButton.x");
    If you are using <input type="button" name="myButton"> with Internet Explorer all of the buttons are deemed "successful". So calling request.getParameter("myButton") will never return null.
    At least thats the way it works in IE6. And thats what I'm stuck with at work right now, so thats what gets used. It may be fixed in later versions, but I don't have any info on that.
    Cheers,
    evnafets

  • Working with 2  submit buttons in a html form

    I have 2 submit buttons in a form. I will upload a file and save in a filepath in server when I click on one "upload" button. I want to use this file path in the code when I click on another button called"Process".  When I click the process nothing is happening with dump in below code.Form  submits to itself. Is there any better way to do this. Thanks in advance.
    <table width="40%" border="0" style="border: 1px solid black;">
              <form  name="uploadform" action="processfile.cfm" enctype="multipart/form-data"  method="post">
              <tr>
                        <td><input type="file"  name="FileContents" size="25">
                            <input type="button" name="action" id="action" value="Upload">
                        </td>
              </tr>
              <tr>
                        <td align="middle">
                                  <input type="button" name="submitaction" id="process" value="Process">
                          </td>
              </tr>
              </form>
        </table>
    <cfset variables.filepath ="">
    <cfif isdefined("form.action") AND form.action eq "upload">
                 <cffile action = "upload"  fileField = "FileContents" destination = "C:\test\" accept = "text/plain" nameConflict="overwrite">
              <cfset variables.filepath= "C:\test\#cffile.serverFile#">
    <cfelseif isdefined("form.submitaction") AND form.submitaction eq "process">
              <cfdump var="#variables.filepath#">
    </cfif>

    Hi tburra,
    You can try the below code. This dumps the value of the path as well.
    <cfif isDefined('Form.tmpfile1')> <cfset root = ExpandPath("/Upload")><!---location where file should be uploaded---> <cfset filename=GetFileFromPath(Form.tmpFile1)> <cfset FileExt=ListLast(filename,".")> <cfset variables.filepath =""> <cfset filename = "BidDocument1." & FileExt>  <cffile action="upload" filefield="BidDoc1" destination="C:\Upload\" nameconflict="overwrite" accept="application/pdf,application/msword,application/vnd.ms-excel,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"> <cfset variables.filepath= "C:\test\#cffile.serverFile#"> <cfdump var="#variables.filepath#"> </cfif> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>cffileupload Document</title> <form name="form1" enctype="multipart/form-data" method="post"> <input type="hidden" name="tmpfile1" value="" /> <input  type="file"  name="BidDoc1"  onchange="setFile(this.form);" /> <input type="submit" name="save1" value="Upload" /> </form> <button onclick="location.href='processfile.cfm'">Process</button> </html>
    This should help you.
    Regards,
    Anit Kumar

Maybe you are looking for