Jump to content
xisto Community
Sign in to follow this  
eddygalvin

Modify Header Error Warning: Cannot modify header information -

Recommended Posts

hello i have written an php to send signups to a webpage on a different sever. But when textrunning, i got a warning error

Warning: Cannot modify header information - headers already sent by (output started at /home/gminds/public_html/SendSignupHttp.php:86) in /home/gminds/public_html/SendSignupHttp.php on line 59

Although the signup process was complete this warning would bounce vistors off my site. i have checked but have not found what was wrong with the script. i have attached the scripts below. Any help on resolving this issue will be highly appreciated. thanks.

 

 

this is the first script SendSignupHttp.php


{

 

/*Require the PostRequest function for posting the API request to the server */

require ("PostRequest.php");

 

$resellerusername = "rock";

$isReseller = $_POST['rbIsReseller'];

$username = $_POST['txtUserName'] ;

$password = $_POST['txtPassword'] ;

$companyname = $_POST['txtCompany'];

$firstname = $_POST['txtFirstName'];

$lastname = $_POST['txtLastName'];

$cellphone = $_POST['txtCellPhoneNumber'];

 

$email = $_POST['txtEmail'];

$address = "";

$city = $_POST['txtCity'];

$state = $_POST['txtState'];

$country = $_POST['txtCountry'];

$emailtosms = "0";

 

/* ==================================================

SUBMIT A REQUEST TO SIGN UP VIA THE HTTP API

=====================================================*/

// submit these variables to the server

$data = array( 'ResellerUN' => $resellerusername ,

'CustomerUN' => $username ,

'IsReseller' => $isReseller,

'FN' => $firstname,

'LN' => $lastname ,

 

'EMAIL' => $email ,

'COMPANY' => $companyname ,

'ADDRESS' => $address ,

'CITY' => $city ,

'STATE' => $state ,

'COUNTRY' => $country ,

'CELL' => $cellphone ,

 

'EmailToSms' => $emailtosms,

'PASSWORD' => $password);

 

// send a request to the API url

list($header, $content) = PostRequest("http linenums:0'><?php function submitSignUpForm(){ if(isset($_POST['txtUserName'])) { /*Require the PostRequest function for posting the API request to the server */ require ("PostRequest.php"); $resellerusername = "rock"; $isReseller = $_POST['rbIsReseller']; $username = $_POST['txtUserName'] ; $password = $_POST['txtPassword'] ; $companyname = $_POST['txtCompany']; $firstname = $_POST['txtFirstName']; $lastname = $_POST['txtLastName']; $cellphone = $_POST['txtCellPhoneNumber']; $email = $_POST['txtEmail']; $address = ""; $city = $_POST['txtCity']; $state = $_POST['txtState']; $country = $_POST['txtCountry']; $emailtosms = "0"; /* ================================================== SUBMIT A REQUEST TO SIGN UP VIA THE HTTP API =====================================================*/ // submit these variables to the server $data = array( 'ResellerUN' => $resellerusername , 'CustomerUN' => $username , 'IsReseller' => $isReseller, 'FN' => $firstname, 'LN' => $lastname , 'EMAIL' => $email , 'COMPANY' => $companyname , 'ADDRESS' => $address , 'CITY' => $city , 'STATE' => $state , 'COUNTRY' => $country , 'CELL' => $cellphone , 'EmailToSms' => $emailtosms, 'PASSWORD' => $password); // send a request to the API url list($header, $content) = PostRequest("http://74.126.82.44/smsapi/CustomerSignUp.aspx?", $data); // display the result of the request //echo $content . '<br>'; $tok = strtok($content, " "); //Split the $content result into words if($tok == "OK") //Success { //Redirect user to the signup thank you page header("Location: signup_thankyou.html"); } else{ //Display the full error message $tok = strtok(" "); $tok = strtok(""); echo $tok . "<br>"; } }}?><!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 content="en-us" http-equiv="Content-Language"><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><title>Untitled 1</title></head><body><table align="center" border="0" cellSpacing="0" width="80%" > <tr> <td style="PADDING-TOP: 10px" vAlign="top" colspan="2"> <h3 align="center">Your enteries have been received 's Back Button to go back</h3> </td> </tr> <tr> <td style="PADDING-TOP: 10px; font-weight:bold; color:red" valign="top" colspan="2" align="center"> <?php submitSignUpForm(); ?> </td> </tr></table></body></html>

this is the secound script PostRequest.php

 

<?php /*=============================================================================================** The function to post a HTTP Request to the provided url passing the $_data array to the API===============================================================================================*/ function PostRequest($url, $_data) { 	// convert variables array to string:	$data = array();		while(list($n,$v) = each($_data)){    	$data[] = "$n=$v";	}		$data = implode('&', $data);	// format --> test1=a&test2=b etc. 	// parse the given URL	$url = parse_url($url);	if ($url['scheme'] != 'http') {     	die('Only HTTP request are supported !');	} 	// extract host and path:	$host = $url['host'];	$path = $url['path']; 	// open a socket connection on port 80	$fp = fsockopen($host, 80); 	// send the request headers:	fputs($fp, "POST $path HTTP/1.1\r\n");	fputs($fp, "Host: $host\r\n");	fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");	fputs($fp, "Content-length: ". strlen($data) ."\r\n");	fputs($fp, "Connection: close\r\n\r\n");	fputs($fp, $data); 	$result = ''; 	while(!feof($fp)) {    	// receive the results of the request    	$result .= fgets($fp, 128);	} 	// close the socket connection:	fclose($fp); 	// split the result header from the content	$result = explode("\r\n\r\n", $result, 2); 	$header = isset($result[0]) ? $result[0] : '';	$content = isset($result[1]) ? $result[1] : ''; 	// return as array:	return array($header, $content);}?>

Share this post


Link to post
Share on other sites

The problem is that you put submitSignUpForm(); within an HTML context. submitSignUpForm() contains a header() function, but the header() function can only work if you did not already send non-header data to the browser.

Share this post


Link to post
Share on other sites

hello i would like to setup a bulk sms website where users will be able to do the following1.users can recharge thier account with recharge vouchers2.send credits to other users on my site and have a referrer system.3.give a signup free sms to my users.I have made some research and i learnt that i require a gateway API to send sms intranet. this i have already done. i would like to know which software or script to install on my webserver that will give those features listed above thanks.thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.