delete form tag

Posted on 2010-03-25
Medium Priority
Last Modified: 2012-06-21
I made the code shorter by deleting the <html> and <head> <body> tags

now I want to delete the form tag
because I want to put this on a content management system that has a form and a jquery table sorter and it is not working on my cms

is this possible
ini_set('error_reporting', E_ALL); 
         if( isset($_POST) && !empty($_POST)) 
                        if(isset($_SESSION['prev']) && $_SESSION['prev']==serialize($_POST)) 
                                echo "Data already processed!"; 
                $msg="You sent " . print_r($_POST,true); 
                //here you can try to save it to the db: 
                //mysql_connect("localhost","username","password") or die($msg."\nunable to connect to server: \n".mysql_error()); 
                //mysql_select_db("dbname") or die($msg."\nUnable to select db: \n" . mysql_error()); 
                //$sql="INSERT INTO tableName(fieldName) VALUES('{$FieldName}')"; 
                //mysql_query($sql) or die($msg."\nUnable to execute query: \n$sql\n".mysql_error()); 
                echo $msg."\nData proccessed successfully"; 

                          <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script> 
                                          var opts={ 
                                                                  url: this.form.action 
                                                                  ,type: this.form.method 
                                                                  ,data:{ } 
//NOTE: ADDED a  return false; 
                                                          return false; 
                          function processResult(data, textStatus){ 
                  <form id='theForm' action='<?php $_SERVER["PHP_SELF"] ?>' method='post'> 
                          <div>Email: <input type='text' id='FieldName' name='FieldName' value=''/></div> 
                          <div><input type='submit' name='Submitter' value='Submit'/></div> 

Open in new window

Question by:rgb192
  • 2
  • 2
LVL 82

Expert Comment

ID: 28592436
it sounds like you are "pasting" that code within the body of your "template". It will not work because the session_start() cannot be called after you have sent output to the browser. You need to call session_start() at the beginning of your "template".

Author Comment

ID: 28593625
could this code be done without a session start....
LVL 82

Accepted Solution

hielo earned 2000 total points
ID: 28594089
>>could this code be done without a session start....
Sure, that is what I did two posts ago on the other threads/posts, BUT you then were complaining that it reposts upon refresh.

If you still want to avoid the refresh problem, you have to remember what was previously posted, and for that you need the $_SESSION.

It's likely that your cms is using $_SESSION. If so, then it must be calling somewhere first, in which case you can just comment out the session_start(); from the code you posted above (since you need to call session_start() only ONCE and presumable the cms already called it ).

Author Closing Comment

ID: 31707272

I have the same question with an earlier version of your code that I removed html,head,body tags without the session


Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question