SitePoint Sponsor |
|
User Tag List
Results 1 to 25 of 25
Thread: Can anyoane please help me?
-
Apr 28, 2005, 05:27 #1
- Join Date
- Apr 2005
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Can anyoane please help me?
I get an error which is driving me mad.
I am trying to redirect to thankyou page from a contact form .
The details will be stored in my database but instead redirection I receive:
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\test\dabisolutions\site\contact_us.php:14) in C:\Program Files\Apache Group\Apache2\test\dabisolutions\site\contact_form1.php on line 55
my code for redirection is:
$insertGoTo = "thankyou.html";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s",$insertGoTo));
on the 14 line in contact_us.php I've got:
<img id="logo1" src="slices/logo.gif" alt="Dabi Solutions - Online Marketing"> AND
on the line 55 on the contact_form1 I've got:
header(sprintf("Location: %s",$insertGoTo));
The contact_form1.php is included in contact_us.php
Please anyone can help me?
Thank you.
-
Apr 28, 2005, 05:40 #2
- Join Date
- Dec 2004
- Location
- ljubljana, slovenia
- Posts
- 684
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well, the error message is quite useful here - it tells you that you cannot post headers, because something else was already posted.
The header you're trying to send (Location: ...) is a HTTP header and as such must be the first thing to be output by your script. Obviously, this is not the case, since you're already outputing some html before.
You could move that header code before that html, this would be the easy way.
-
Apr 28, 2005, 05:51 #3
Originally Posted by dbevfat
Erh
-
Apr 28, 2005, 05:51 #4
- Join Date
- Apr 2005
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This is all my php script from contact_form1 followed (not-posted) by the usual html code with the input tags for my contact form.
I don't have any html wich is sendind the page to thankyou.html.
Can you plase have a look and tell me where I've made a mistake?
Thank you again.
<?php
require_once('../Connections/contactform1.php');
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO clients_for_newsletter (first_name, second_name, company, email, web, tel, mobile, fax, Address, city, country, enquiries, checkbox) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['first_name'], "text"),
GetSQLValueString($_POST['second_name'], "text"),
GetSQLValueString($_POST['company'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['web'], "text"),
GetSQLValueString($_POST['tel'], "int"),
GetSQLValueString($_POST['mobile'], "int"),
GetSQLValueString($_POST['fax'], "int"),
GetSQLValueString($_POST['Address'], "text"),
GetSQLValueString($_POST['city'], "text"),
GetSQLValueString($_POST['country'], "text"),
GetSQLValueString($_POST['enquiries'], "text"),
GetSQLValueString(isset($_POST['checkbox']) ? "true" : "", "defined","'Y'","'N'"));
mysql_select_db($database_contactform1, $contactform1);
$Result1 = mysql_query($insertSQL, $contactform1) or die(mysql_error());
}
$insertGoTo = "thankyou.html";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s",$insertGoTo));
?>
-
Apr 28, 2005, 05:52 #5
See my above post.
Erh
-
Apr 28, 2005, 06:00 #6
- Join Date
- Apr 2005
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I've got this error now:
Parse error: parse error, unexpected T_REQUIRE_ONCE in C:\Program Files\Apache Group\Apache2\test\dabisolutions\site\contact_form1.php on line 2
The require file is my config. file to connect to the database, apache.........
And I cannot see my contact form no more.
-
Apr 28, 2005, 06:05 #7
Originally Posted by catalin
Erh
-
Apr 28, 2005, 06:11 #8
- Join Date
- Dec 2004
- Location
- ljubljana, slovenia
- Posts
- 684
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This is a completely different problem. The first one that you described was caused by the html code in line 14 of file contact_us.php, so you actually _did_ have some html code output before the headers.
In this code you posted, you're including a file called contactform1.php, which probably has some html code in it? That html is sent to the browser before your header() call is made. Mandibal and I told you how to solve this.
About this last error, not sure what causes it, it looks like some syntax error, but I cannot say more until I see your code. The one posted in your previous post looks ok, did you change anything?
Regards
-
Apr 28, 2005, 06:12 #9
- Join Date
- Apr 2005
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
My script is looking like that now:
I hope the script is undestandable
<?php ob_start()
require_once ("../contactform1.php");
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO clients_for_newsletter (first_name, second_name, company, email, web, tel, mobile, fax, Address, city, country, enquiries, checkbox) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['first_name'], "text"),
GetSQLValueString($_POST['second_name'], "text"),
GetSQLValueString($_POST['company'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['web'], "text"),
GetSQLValueString($_POST['tel'], "int"),
GetSQLValueString($_POST['mobile'], "int"),
GetSQLValueString($_POST['fax'], "int"),
GetSQLValueString($_POST['Address'], "text"),
GetSQLValueString($_POST['city'], "text"),
GetSQLValueString($_POST['country'], "text"),
GetSQLValueString($_POST['enquiries'], "text"),
GetSQLValueString(isset($_POST['checkbox']) ? "true" : "", "defined","'Y'","'N'"));
mysql_select_db($database_contactform1, $contactform1);
$Result1 = mysql_query($insertSQL, $contactform1) or die(mysql_error());
}
$insertGoTo = "thankyou.html";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s",$insertGoTo));
exit()
?>
-
Apr 28, 2005, 06:15 #10
Most likely the problem is that ob_start(); needs to be on a line by itself like this:
PHP Code:<?php
ob_start();
require_once ("../contactform1.php");
...Erh
-
Apr 28, 2005, 06:19 #11
- Join Date
- Apr 2005
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I've got the error on line3 now
Parse error: parse error, unexpected T_REQUIRE_ONCE in C:\Program Files\Apache Group\Apache2\test\dabisolutions\site\contact_form1.php on line 3
-
Apr 28, 2005, 06:23 #12
Originally Posted by catalin
Erh
-
Apr 28, 2005, 06:28 #13
- Join Date
- Apr 2005
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I've put the semicolon after ob_start [ ex: ob_start () { ] and I've close it
before exit() and I have the following error now
Parse error: parse error, unexpected '{' in C:\Program Files\Apache Group\Apache2\test\dabisolutions\site\contact_form1.php on line 2.
There is any other way to redirect my contact form after submitting to my thank you page?
-
Apr 28, 2005, 06:36 #14
Originally Posted by catalin
Last edited by Mandibal; Apr 28, 2005 at 06:38. Reason: Read spikz post and realized that I misread the error and what catalin said.
Erh
-
Apr 28, 2005, 06:36 #15
- Join Date
- Aug 2004
- Location
- Manchester UK
- Posts
- 13,807
- Mentioned
- 158 Post(s)
- Tagged
- 3 Thread(s)
Semi colon is ;
brace is {
PHP Code:<?php
ob_start();
require_once ("../contactform1.php");
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO clients_for_newsletter (first_name, second_name, company, email, web, tel, mobile, fax, Address, city, country, enquiries, checkbox) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['first_name'], "text"),
GetSQLValueString($_POST['second_name'], "text"),
GetSQLValueString($_POST['company'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['web'], "text"),
GetSQLValueString($_POST['tel'], "int"),
GetSQLValueString($_POST['mobile'], "int"),
GetSQLValueString($_POST['fax'], "int"),
GetSQLValueString($_POST['Address'], "text"),
GetSQLValueString($_POST['city'], "text"),
GetSQLValueString($_POST['country'], "text"),
GetSQLValueString($_POST['enquiries'], "text"),
GetSQLValueString(isset($_POST['checkbox']) ? "true" : "", "defined","'Y'","'N'"));
mysql_select_db($database_contactform1, $contactform1);
$Result1 = mysql_query($insertSQL, $contactform1) or die(mysql_error());
}
$insertGoTo = "thankyou.html";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s",$insertGoTo));
exit()
?>Mike Swiffin - Community Team Advisor
Only a woman can read between the lines of a one word answer.....
-
Apr 28, 2005, 06:43 #16
- Join Date
- Apr 2005
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I am sorry SpikeZ.
I have to improve my english.
I've tryed now with the semicolon aswell but still no change.
Mandibal I've checked my contact_form1.
The file is all the php script which I've posted above plus some html.
-
Apr 28, 2005, 06:50 #17
- Join Date
- Aug 2004
- Location
- Manchester UK
- Posts
- 13,807
- Mentioned
- 158 Post(s)
- Tagged
- 3 Thread(s)
If the code above is contact_form1.php, why are you using a require() if the contents of contact_form1.php include your mysql_pconnect() then fine, use require but there really shouldn't be much else in it.
(you can't include the file you are using in the the file you are using!!!)
Cheers
SpikeZMike Swiffin - Community Team Advisor
Only a woman can read between the lines of a one word answer.....
-
Apr 28, 2005, 06:56 #18
- Join Date
- Apr 2005
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
this is my required file
<?php
$hostname_contactform1 = "localhost";
$database_contactform1 = "contact";
$username_contactform1 = "username";
$password_contactform1 = "password";
$contactform1 = mysql_pconnect($hostname_contactform1, $username_contactform1, $password_contactform1) or trigger_error(mysql_error(),E_USER_ERROR);
?>
-
Apr 28, 2005, 07:04 #19
- Join Date
- Aug 2004
- Location
- Manchester UK
- Posts
- 13,807
- Mentioned
- 158 Post(s)
- Tagged
- 3 Thread(s)
I was looking back to your first post....
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\test\dabisolutions\site\contact_us.php:14) in C:\Program Files\Apache Group\Apache2\test\dabisolutions\site\contact_form1.php on line 55
There is nothing wrong with the code you posted in post#9, the problem is on contact_us.php line 14. Could you be a darling and post the contact us page code!
Cheers
SpikeZMike Swiffin - Community Team Advisor
Only a woman can read between the lines of a one word answer.....
-
Apr 28, 2005, 07:09 #20
- Join Date
- Apr 2005
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This is my contact_us page.
I think I've seen the problem.
I've highlighted the php code in this file and I dont think is in the right position but if I'm going to change that all in my page will be messed up.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Dabi Solutions - Contact us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="styleservices.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="main">
<div id="logo">
<img id="logo1" src="slices/logo.gif" alt="Dabi Solutions - Online Marketing">
</div>
<div id="topnav">
<ul>
<li id="home"><a href="index.html">about us</a></li>
<li id="services"><a href="services.html">services</a></li>
<li id="clients"><a href="clients.html">clients</a></li>
<li id="contact"><a href="contact_us.php">contact us</a></li>
<li id="sitemap"><a href="../forum/index.php">forum</a></li>
</ul>
</div>
<div id="title1">
<p id="p1">Links to our site</p>
</div>
<div id="title2">
<h1>Contact Us</h1>
</div>
<div id="rightnav">
<ul>
<li id="seo"><a href="index.html">about us</a></li>
<li id="ppc"><a href="location.html">location</a></li>
</ul>
</div>
<div id="text">
<?php include "contact_form1.php"?>
</div>
<div id="footer">
<img id="roflag" src="images/ro.png" alt="Romanian Version">
<ul>
<li><a href="index.html">about us</a></li>
<li><a href="privacy_policy.html">privacy policy</a></li>
<li><a href="site_map.html">site map</a></li>
<li><a href="../forum/index.php">forum</a></li>
</ul>
</div>
<div id="copyright">
<p id="pc">
Copyright © 2005. All rights reserved.<br>
No part of this website may be reproduced in any form
without the express written consent of Dabi Solutions.
</p>
</div>
</div>
</boby>
</html>
-
Apr 28, 2005, 07:13 #21
- Join Date
- Aug 2004
- Location
- Manchester UK
- Posts
- 13,807
- Mentioned
- 158 Post(s)
- Tagged
- 3 Thread(s)
AAAAAAAAAAAAAAAAAAAAAALRIGHTY THEN, now we are cookin'.
The problem as you rightly say is that the form is being included way down the page.
Here's what you can do....
1./ on your page with the form, cut the form out of the coding leaving all the php above alone,
2./ paste the form into the above contact_us page. so now you have the form on the page and change the form action to contact_form1.php (the page with the code still on it)
3./ sit back and relax!
SpikeZMike Swiffin - Community Team Advisor
Only a woman can read between the lines of a one word answer.....
-
Apr 28, 2005, 07:15 #22
- Join Date
- Apr 2005
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I've changed the position of the included file and it's redirect me straight away but I don't have the chance to fill the contact form
.
So when i hit the contact tab I will see the thank you page instead the form
-
Apr 28, 2005, 07:19 #23
- Join Date
- Apr 2005
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well well well my big mystery has been solved.
Thank you very much
-
Apr 28, 2005, 07:38 #24
- Join Date
- Aug 2004
- Location
- Manchester UK
- Posts
- 13,807
- Mentioned
- 158 Post(s)
- Tagged
- 3 Thread(s)
woooooooooooooooo hoooooooooooooooooo strike on for the fat boy!
Glad you got it sorted catalin!
SpikeZMike Swiffin - Community Team Advisor
Only a woman can read between the lines of a one word answer.....
-
Apr 28, 2005, 07:55 #25
- Join Date
- Apr 2005
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanks again
You're the man.
Bookmarks