Jump to content

how to process form in better way


stribor40

Recommended Posts

i already completed this part,.

 

form1.html data gets entered and processed with form1.php. Data is passed with ajax. This form has only one button to submit form.

 

Now i have form2.html which is exaclty same as form1.html. It is processed with form2.php and it shows data entered in form1.html and the only difference is that it shows 2 buttons instead of 1. 

 

Is there anyway that I can get this done using only one html and php rather than using 2 html and 2 php files.

 

any suggestion is much appreciated.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/280780-how-to-process-form-in-better-way/
Share on other sites

You might be able to do what you talking about with an if statement. For example I do that with a form I'm using

    protected function addForm($formPage, $sticky, $title = NULL, $content=NULL) {
        // Creat a form:
        $this->getForm = '<div id="format-form">';
        $this->getForm .= '<form action="' . $formPage . '" method="post">';
        $this->getForm .= '<input type="hidden" name="action" value="enter" />';
        
        if ($sticky == 'yes') {
            $this->getForm .= '<select id="basic" name="sticky">';
            $this->getForm .= '<option selected="selected" value="no">Sticky Thread?</option>';
            $this->getForm .= '<option value="yes">yes</option>';
            $this->getForm .= '<option value="no">no</option>';
            $this->getForm .= '<option value="sysop">sysop</option>';
            $this->getForm .= '</select>';
        }
           
        if (isset($title)) {
            $this->getForm .= '<br><br>';
            $this->getForm .= '<label class="label-styling" for="style-title" >Title</label>';
            $this->getForm .= '<br>';
            $this->getForm .= '<input type="text" maxlength="40" id="style-title" name="title" value="' . $title . '">';
            $this->getForm .= '<br>';
        }
        
        $this->getForm .= '<br><br>';
        $this->getForm .= '<label class="label-styling" for="style-textarea">Content</label>';
        $this->getForm .= '<textarea class="expanding" name="content" id="content-style">' . $content . '</textarea>';
        $this->getForm .= '<br>';
        $this->getForm .= '<input class="submit-btn-style" type="submit" name="submit" value="Submit Blog">';
        $this->getForm .= '<br>';
        $this->getForm .= '</form>';
        
        return $this->getForm;

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.