PHP - Header Message
the script below works but i have started getting this error
Quote Warning: Cannot modify header information - headers already sent by (output started at /hermes/bosweb/web230/b2302/ipg.myaccount/test_server/admin/index.php:10) in /hermes/bosweb/web230/b2302/ipg.myaccount/test_server/admin/index.php on line 95 line 95 is this bit header('Location: index.php'); <?php // Set Global Vars $HOST = "xxxxxxxxxx"; $USERNAME = "xxxxxxxxx"; $PASSWORD = "xxxxxxxxx"; $DATABASE = "group"; $TABLE = "Testimonials"; // Establish a connection mysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error()); mysql_select_db($DATABASE) or die(mysql_error()); //================================================================== // Check if anything is posted //================================================================== if (isset($_POST['delete'])) { $sql = ("delete from $TABLE where "); for ($i = 0; $i < count($_POST['checkbox']); $i++) { if ($i != 0) { $sql.= "OR "; } $sql .= " id='" . $_POST['checkbox'][$i] . "'"; //================================================================== // Select file to unlink based on id posted //================================================================== $sql_file_unlink = "select Download from $TABLE where id = {$_POST['checkbox'][$i]}"; $result_file_unlink = mysql_query($sql_file_unlink); $row_file_link = mysql_fetch_assoc($result_file_unlink); if($row_file_link) { unlink('../testimonial_files/' . $row_file_link['Download']); } //================================================================== } $result = mysql_query($sql); header('Location: index.php'); exit; } else { // select sql here $sql = "select * from `$TABLE` order by `id`;"; $result = mysql_query($sql); } ?> <table align="center" width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td colspan="6" align="center"><strong>Testimonials</strong> </td> </tr> <tr> <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <table width="400" border="1" cellpadding="3" cellspacing="1"> <tr> <td align="center"><strong>Select</strong></td> <td align="center"><strong>ID</strong></td> <td align="center"><strong>Name</strong></td> <td align="center"><strong>Description</strong></td> <td align="center"><strong>Download</strong></td> <td align="center"><strong>Last Modified</strong></td> </tr> <?php $row = mysql_fetch_assoc($result); ?><?php do { ?> <tr> <td align="center"> <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>"> </td> <td align="center"><?php echo $row['id']; ?></td> <td align="center"><?php echo $row['Name']; ?></td> <td align="center"><?php echo $row['Message']; ?></td> <td align="center"><a href="../testimonial_files/<?php echo $row['Download']; ?>">Download</a></td> <td align="center"><?php echo date("j/n/y", strtotime($row["Modified"])) ?></td> </tr> <?php } while ($row = mysql_fetch_assoc($result)); ?> <tr> <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> </table> </form> </td> </tr> </table> Similar TutorialsThis is the error message: Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/main.php:12) in /home/public_html/main.php on line 61 I've tried reading into this but find no solutions if anyone can help I would be very grateful. I'm just trying to get the code to take the user to register page if they not a member heres the code im using <table border="0" width="220" align="center"> <tr> <? if(!session_is_registered("username")){ // if session variable "username" does not exist. echo "<td width='71'>Username:</td> <td width='139'><input type='text' name='username' size='16' style='font-family: Times New Roman, Times, serif; font-size: 11pt;' /></td> </tr> <tr> <td width='71'>Password:</td> <td width='139'><input type='password' name='password' size='16' style='font-family: Times New Roman, Times, serif; font-size: 11pt;' /></td> </tr> <tr> <td colspan='2' align='center'><input name='login' type='submit' value='Log In' style='background-color: #900002; border-color: #555555; color: #FFFFFF; font-weight: bold; width: 60px;' /></td>"; }else{ echo "<td><b>Welcome $username</b><br /><a href='logout.php'><b>Logout</b></a></td>"; } ?> </tr> </table> </form></div> <div id="menutext"><span class="class1"><a href="http://www.fightwatcher.com">Home</a> <a href="http://www.fightwatcher.com">News</a> <a href="http://www.fightwatcher.com">Profile</a> <a href="http://www.fightwatcher.com">Friends & Fighters</a> <a href="http://www.fightwatcher.com">Videos</a> <a href="http://www.fightwatcher.com">Groups</a> <a href="http://www.fightwatcher.com">Forum</a></span></div> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <? if(!session_is_registered("username")){ header("Location: http://www.fightwatcher.com/register.html"); }else{ include("connect.php"); $result = mysql_query("SELECT * FROM signup ORDER by date AND time LIMIT 10"); echo "<table cellpadding=0 cellspacing=0 width=163> <tr bgcolor=#990000><td colspan=2 align=center height=24><font color=#FFFFFF><b>Newest Users:</b></font></td></tr>"; while($row = mysql_fetch_array($result)) { $username = $row['username']; $gender1 = $row['gender']; if ($gender1=="male") { $gender2="<font color=#0066FF><b>M</b></font>"; } if ($gender1=="female") { $gender2="<font color=#FF33CC><b>F</b></font>"; } echo "<tr><td align=center width=100>$username</td><td align=center width=57>$gender2</td></tr>"; } echo "</table>"; } ?> </body> Thanks Hi All, I just formatted my HD and had a WAMP setup. I have not installed each component separately (newest versions). When I type in a text box and press the submit button, I get: Warning: Cannot modify header information - headers already sent by (output started at D:\Web\Apache\htdocs\projects\tms_new\functions\functions.js:304) in D:\Web\Apache\htdocs\projects\tms_new\apps\index.php on line 167 Line 304 in the functions.js file is: </script> Line 167 in index.php is: header('Location: index.php?lastname='.stripslashes($lastname)); It says I am sending header information before line 167, but there isn't any. The .JS file only has JS code. Can someone give me any suggestions? Thanks everyone!! I have this working script below. I never managed to turn it into a function... I think it's because there's classes in it.
I stopped that investigation and instead I choose to:- keep it on another page, trigger it with the a <form> button, then return to the form page using header location. This is probably much more elaborate than it needs to be... but it seems to be working fine.
I'd like to print out "email sent" if successful. The collection of confusion at the end of this script, is me trying to get it to return the - "email sent" message <index.php> <?php require 'includes/PHPMailer.php'; require 'includes/SMTP.php'; require 'includes/Exception.php'; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = "smtp.gmail.com"; $mail->SMTPAuth = "true"; $mail->SMTPSecure = "tls"; $mail->Port = "587"; $mail->Username = "email@gmail.com"; $mail->Password = "pass"; $mail->Subject = "Test email using PhPmailer"; $mail->setFrom("email@gmail.com"); $mail->isHTML(true); //$mail->addAttachment('img/movie.mp4'); $mail->Body = "<h1>This is a HTML heading</h1></br><p>This is a html title</p>"; $mail->addAddress("email@gmail.com"); if ($mail->Send() ) { echo "Email sent..!"; } else{ echo "Error..!"; } $mail->smtpClose(); ob_start(); $Message = urlencode("Email Sent"); header("Location:EmailBut.html?Message=".$Message); die; ob_flush(); ?> The stuff at the beginning of this next script is me trying to get it to print out email sent. I can get it to return the message in the URL but it won't print out. <EmailBut.html> <?php ob_start(); if(isset($_GET['Message'])){ echo $_GET['Message']; } echo $_GET['Message']; ob_flush(); ?> <html> <body> <form action="index.php" method="POST"> <button type="submit">Send</button> </form> </body> </html> Can you please give me a push in the right direct here? Edited January 30, 2020 by JonnyDrillerHello everyone, I'm just starting out with PHP as I need to create an online bookstore for a school project. I'm working by a magazine which should teach you exactly how to do this using PHP, but I've had a bunch of problems with the code they use and I don't really know what's going on. Anyway, this looks really simple and basically what it does is allows you to post a comment on a book, then returns you to the book's page. Problem is, I'm getting the Header may not contain more than a single header, new line detected. error and I can't figure out why. I've tried researching into the matter but all the cases I found had to do with returning to an url, which is not my case. Anyway, here's the snippet of code: The form: Code: [Select] <div style="width:400px; border:1px solid #ffffff; background-color:#F9F1E7; padding:5px"> <b>Adauga opinia ta:</b> <hr size="1"> <form action="adauga_comentariu.php" method="POST"> Nume: <input type="text" name="nume_utilizator"><br><br> Email: <input type="text" name="adresa_email"><br><br> Comentariu: <br> <textarea name="comentariu" cols="45"></textarea><br><br> <input type="hidden" name="id_carte" value="<?=id_carte?>"> <center><input type="submit" value="Adauga"</center> </form> </div> The script adaugare_comentariu.php: Code: [Select] <?php ob_start(); include("conectare.php"); $numeFaraTags=strip_tags($_POST['nume_utilizator']); $emailFaraTags=strip_tags($_POST['adresa_email']); $comentariuFaraTags=strip_tags($_POST['comentariu']); $sql="insert into comentarii (id_carte, nume_utilizator, adresa_email, comentariu) values(".$_POST['id_carte'].", '".$numeFaraTags."','".$emailFaraTags."','".$comentariuFaraTags."')"; mysql_query($sql); $inapoi="carte.php?id_carte=".$_POST['id_carte']; header("location:urldecode($inapoi)"); ob_end_flush(); ?> conectare.php connects to the mysql database. $inapoi is the variable which returns the user to carte.php (the book he posted a comment on), where id_carte is the book's unique id. I'm getting Header may not contain more than a single header, new line detected on line ten, which is the header line. Can anyone help me? I've been stumped on this for a few days now and I've just let it pass and started working on other bits, but it's bugging me too much and I'd like to fix it. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=350027.0 Hey Guys, I have followed a tutorial and got a SMS text message script working. Although what i would like to do now is allow a registered user to add another user via a form. This form will contain the users mobile number, email, who its from, and a textarea for the message to send to them in the text message. *** It also stores it into a database. But dont worry about that. I have run into a problem, when i type in a mobile number and an email address and then press send. It doesnt seem to store the email address in the $vars echo (message). **It does echo in the email bit but i wont it to show in the message bit. ** Here is a screenshot. right ive setup my own messaging feature on my website but it still allowes me to message myself if tried <? }else{ if($to == username){ ?> the whole code so you can get a better understanding <?php session_start(); include_once "includes/db_connect.php"; include_once "includes/functions.php"; logincheck(); $username=$_SESSION['username']; $fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'")); if ($fetch->texts < '1'){ echo "<font color=red>You don't have No Texts Left</font><br>"; }elseif($fetch->texts >= '1'){ ?> <body onLoad="goaway();"><? $towho=$_GET['fromper']; $oldmsg=$_GET['oldmsg']; $text=$_POST['text']; $subject=$_POST['subject']; $fsubject=$_GET['fsubject']; $info=mysql_fetch_object(mysql_query("SELECT rank FROM users WHERE username='$username'")); $goody = mysql_query("SELECT `inbox`, `date`, `from` FROM `messages` WHERE `id`='$rep'"); while($success = mysql_fetch_row($goody)){ $ini = $success[0]; $dateon = $success[1]; $fromper = $success[2]; } if(strip_tags($_POST['Send'])){ $text=strip_tags(addslashes($text)); $to = strip_tags(addslashes($_POST['to'])); $rep = $_GET['rep']; if((!$to)){ ?> <p class="style4">Please enter a username!</p> <span class="style4"> <? }else{ if(!$text){?> </span> <p class="style4">You cannot send a blank message!</p> <span class="style4"> <? }else{ if($to == username){ ?> </span> <p class="style4">You cannot send a message to yourself!</p> <span class="style4"> <? }else{ $sql_username_check = mysql_query("SELECT username FROM users WHERE username='$to'"); $username_check = mysql_num_rows($sql_username_check); if ($username_check == 0){ ?> </span> <p class="style4">Invalid Username!</p> <span class="style4"> <? }else{ $date = gmdate('Y-m-d H:i:s'); $sql = mysql_query("INSERT INTO `inbox` (`id`, `to`, `from`, `message`, `date`, `read`, `subject`) VALUES ('', '$to', '$username', '$text', '$date', '0', '$subject');") or die (mysql_error()); $sqll = mysql_query("UPDATE users SET texts = texts-1 WHERE username='$username'"); if(!$sql){ ?> </span> <p class="style4">There has been an error please contact an Admin !</p> <span class="style1"> <? }else{ echo "<table width=300 border=1 align=center cellpadding=0 cellspacing=0 bordercolor=#003300 class=thinline2> <tr> <td height=20 align=center bgcolor=#74CE59 scope=col><span class=style1>Your Message As Been Sent </span></td> </tr> </table>"; }}}}}} ?> Let me know if i am understanding this correctly Below is the form code i put in my HTML editor followed by the php code that i right out as a text doc. then save as .php and upload to the appropriate location? if the above is correct what do i name the php file scripts/send_sms.php? when i do it this way i get this error message Not Found The requested URL /scripts/sms_error.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Code: [Select] <?php $from = $_POST['from']; $to = $_POST['to']; $carrier = $_POST['carrier']; $message = stripslashes($_POST['message']); if ((empty($from)) || (empty($to)) || (empty($message))) { header ("Location: sms_error.php"); } else if ($carrier == "verizon") { $formatted_number = $to."@vtext.com"; mail("$formatted_number", "SMS", "$message"); // Currently, the subject is set to "SMS". Feel free to change this. header ("Location: sms_success.php"); } else if ($carrier == "tmobile") { $formatted_number = $to."@tomomail.net"; mail("$formatted_number", "SMS", "$message"); header ("Location: sms_success.php"); } else if ($carrier == "sprint") { $formatted_number = $to."@messaging.sprintpcs.com"; mail("$formatted_number", "SMS", "$message"); header ("Location: sms_success.php"); } else if ($carrier == "att") { $formatted_number = $to."@txt.att.net"; mail("$formatted_number", "SMS", "$message"); header ("Location: sms_success.php"); } else if ($carrier == "virgin") { $formatted_number = $to."@vmobl.com"; mail("$formatted_number", "SMS", "$message"); header ("Location: sms_success.php"); } ?> Code: [Select] <form id="sms" name="sms" method="post" action="scripts/send_sms.php"> <table width="400"> <tr> <td align="right" valign="top">From:</td> <td align="left"><input name="from" type="text" id="from" size="30" /></td> </tr> <tr> <td align="right" valign="top">To:</td> <td align="left"><input name="to" type="text" id="to" size="30" /></td> </tr> <tr> <td align="right" valign="top">Carrier:</td> <td align="left"><select name="carrier" id="carrier"> <option value="verizon">Verizon</option> <option value="tmobile">T-Mobile</option> <option value="sprint">Sprint</option> <option value="att">AT&T</option> <option value="virgin">Virgin Mobile</option> </select></td> </tr> <tr> <td align="right" valign="top">Message:</td> <td align="left"><textarea name="message" cols="40" rows="5" id="message"></textarea></td> </tr> <tr> <td colspan="2" align="right"><input type="submit" name="Submit" value="Submit" /></td> </tr> </table> </form> Code: [Select] switch($_GET['action']){ case 'write_ok': $error=false; $msg=''; if($_POST['dateofbirth']=='' || !preg_match( "/^(19|20)\d\d[-\\./](0[1-9]|1[012])[-\\./](0[1-9]|[12][0-9]|3[01])$/",$_POST['dateofbirth'])){ $error=true; $msg.='Date of birth is required and in the correct format 00/00/0000\n'; } the message at the end appears if the error is true. I wanted to know how to not show an errors message if the error is false. Any help on this? hello, this is part of my contact form code. When i click on the submit button i need the form to take me to the $success_message or the $failure_message instead of the top of the page. I know i can do it with # tag or # id normally. But I do not know how to apply it to the form. Code: [Select] //some text and stuff<tr> <td> <? if(!empty($success_message)) { echo "<center><font color='blue'><b>".$success_message."</b></font><br></p>"; } if(!empty($failure_message)) { echo "<center><font color='red'><b>".$failure_message."</b></font><br></p>"; } ?> <? if((empty($_POST)) || !empty($strError)) { echo "<table align= 'center' width='70%' style='border-top: 1px; border-right: 1px; border-left: 1px; border-bottom: 1px; border-color: black; border-style: solid;'>"; ?> <form action="<?php echo $PHP_SELF;?>" method="post"> <tr height='40'> <td> <font color="black"><B> First Name: </B></font> </td> <td><input type="text" size ="40" name="first_name" value="<? if(!empty($strError)) {echo cleaninput($_POST['first_name']);}?>" class="advertising-inputbox-style" /> <?php if (!empty($arrErrors['first_name'])) echo $arrErrors['first_name']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Last Name: </B></font></td> <td><input type="text" size ="40" name="last_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['last_name']);}?>" class="advertising-inputbox-style"/> <?php if (!empty($arrErrors['last_name'])) echo $arrErrors['last_name']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Email Address: </B></font></td> <td><input type="text" size ="40" name="email_address" value="<? if(!empty($strError)) { echo cleaninput($_POST['email_address']);}?>" class="advertising-inputbox-style"/> <?php if (!empty($arrErrors['email_address'])) echo $arrErrors['email_address']; ?> </td> </tr> <tr height='35'> <td><font color="black"><B> Business Name: </B></font></td> <td><input type="text" size ="40" name="business_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['business_name']);}?>" class="advertising-inputbox-style" /> <?php if (!empty($arrErrors['business_name'])) echo $arrErrors['business_name']; ?> </td> </tr> <tr> <td><font color="black"><B> Business Description: </B></font></td> <td ><textarea rows=7 cols=31 name="description" class="advertising-textarea-style"><? if(!empty($strError)) { echo cleaninput($_POST['description']);}?></textarea> <?php if (!empty($arrErrors['description'])) echo $arrErrors['description']; ?> </td> <tr height='35'> <td></td> <td><input type="submit" name="submit" value="submit" /></td> </tr> </form> Basically, All I want to do is save a .txt (doesn't have to be .txt) to my FTP and PHP simple echos it. The .txt is where a message is stored. But when I write the message my self like this: Hello This is a message. - And then upload it to my FTP, PHP echos it like this "HelloThis is a message". Is there anyway for PHP to notice the 'white space'? --OR-- If you know of a better way to make a message system, then also let me know Thanks, Ollie! My code work and let me log in but whether the login is correct or not it keeps on displaying "Wrong username and password" if($count==1){ session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } Here are some script that i have been working on and i seems to not work so i want to make a select friend list that when they select the friend that they want to send the message to it sends it to them , that sounded stupid but ya. so here is my script , kinda big . pm_inbox.php i did edit the code from its original state because its to big! so here is the sections where is most needed Code: [Select] <?php // Start_session, check if user is logged in or not, and connect to the database all in one included file include_once("scripts/checkuserlog.php"); ?> <?php if (!isset($_SESSION['idx'])) { echo '<br /><br /><font color="#FF0000">Your session has timed out</font> <p><a href="login.php">Please Click Here</a></p>'; exit(); } //THIS IS WHERE I STARTED $selecteduser = $_POST["selecteduser"]; $id = ""; $username = ""; $id = preg_replace('#[^0-9]#i', '', $id); $sql = mysql_query("SELECT * FROM myMembers WHERE id='$id' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $username = $row["username"]; $friend_array = $row["friend_array"]; $check_pic = "members/$id/image01.jpg"; $default_pic = "members/0/image01.jpg"; if (file_exists($check_pic)) { $user_pic = "<img src=\"$check_pic?$cacheBuster\" width=\"218px\" />"; } else { $user_pic = "<img src=\"$default_pic\" width=\"218px\" />"; } $selecteduser .= "<option value='$friend_array'>Friends</option>"; } // Decode the Session IDX variable and extract the user's ID from it $decryptedID = base64_decode($_SESSION['idx']); $id_array = explode("p3h9xfn8sq03hs2234", $decryptedID); $my_id = $id_array[1]; $my_uname = $_SESSION['username']; // Put user's first name into a local variable // ------- ESTABLISH THE INTERACTION TOKEN --------- $thisRandNum = rand(9999999999999,999999999999999999); $_SESSION['wipit'] = base64_encode($thisRandNum); // Will always overwrite itself each time this script runs // ------- END ESTABLISH THE INTERACTION TOKEN --------- ?> <?php // Mailbox Parsing for deleting inbox messages if (isset($_POST['deleteBtn'])) { foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); if ($key != "deleteBtn") { $sql = mysql_query("UPDATE private_messages SET recipientDelete='1', opened='1' WHERE id='$value' AND to_id='$my_id' LIMIT 1"); // Check to see if sender also removed from sent box, then it is safe to remove completely from system } } header("location: pm_inbox.php"); } ?> // Start Private Messaging stuff $('#pmForm').submit(function(){$('input[type=submit]', this).attr('disabled', 'disabled');}); function sendPM ( ) { var pmSubject = $("#pmSubject"); var pmTextArea = $("#pmTextArea"); var sendername = $("#pm_sender_name"); var senderid = $("#pm_sender_id"); var recName = $("#pm_rec_name"); var recID = $("#pm_rec_id"); var pm_wipit = $("#pmWipit"); var url = "scripts_for_profile/private_msg_parse.php"; if (pmSubject.val() == "") { $("#interactionResults").html('<img src="images/round_error.png" alt="Error" width="31" height="30" /> Please type a subject.').show().fadeOut(6000); } else if (pmTextArea.val() == "") { $("#interactionResults").html('<img src="images/round_error.png" alt="Error" width="31" height="30" /> Please type in your message.').show().fadeOut(6000); } else { $("#pmFormProcessGif").show(); $.post(url,{ subject: pmSubject.val(), message: pmTextArea.val(), senderName: sendername.val(), senderID: senderid.val(), rcpntName: recName.val(), rcpntID: recID.val(), thisWipit: pm_wipit.val() } , function(data) { $('#private_message').slideUp("medium"); $("#interactionResults").html(data).show().fadeOut(10000); document.pmForm.pmTextArea.value=''; document.pmForm.pmSubject.value=''; $("#pmFormProcessGif").hide(); }); } }function toggleViewAllFriends(x) { if ($('#'+x).is(":hidden")) { $('#'+x).fadeIn(200); } else { $('#'+x).fadeOut(200); } } // End Private Messaging stuff</script> <style type="text/css"> .hiddenDiv{display:none} #pmFormProcessGif{display:none} .msgDefault {font-weight:bold;} .msgRead {font-weight:100;color:#666;} </style> </head> <body> <div id="bg" class="stage"></div> <div id="container"> <div id="sun" class="stage"></div> <div id="clouds" class="stage"> <div id="stage" class="stage"> <?php include_once "header_template.php"; ?> <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers('private_message');">Compose Message</a></div><div class="interactContainers" id="private_message"> <form action="javascript:sendPM();" name="pmForm" id="pmForm" method="post" type="hidden"> <font size="+1">Send A Private Message to <strong><em><?php echo "$selecteduser"; ?></em></strong></font><br /><br /> Subject: <input name="pmSubject" id="pmSubject" type="text" maxlength="64" style="width:98%;" /> Message: <textarea name="pmTextArea" id="pmTextArea" rows="8" style="width:98%;"></textarea> <input name="pm_sender_id" id="pm_sender_id" type="hidden" value="<?php echo $_SESSION['id']; ?>" /> <input name="pm_sender_name" id="pm_sender_name" type="hidden" value="<?php echo $_SESSION['username']; ?>" /> <input name="pm_rec_id" id="pm_rec_id" type="hidden" value="<?php echo $id; ?>" /> <input name="pm_rec_name" id="pm_rec_name" type="hidden" value="<?php echo $username; ?>" /> <input name="pmWipit" id="pmWipit" type="hidden" value="<?php echo $thisRandNum; ?>" /> <span id="PMStatus" style="color:#F00;"></span> <br /><input name="pmSubmit" type="submit" value="Submit" /> or <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers('private_message');">Close</a> <span id="pmFormProcessGif" style="display:none;"><img src="images/loading.gif" width="28" height="10" alt="Loading" /></span></form> </div> <span id="jsbox" style="display:none"></span> </td> </tr> </table> im trying to get new user messages to show up on my site.. i have looked around on google but can only find info on popup alerts.. i just need a simple javscript code that will display the number of new messages next to the link that takes them to their inbox.. if someone could point me to a site or if they have the code handy i would appreciate it more than you know.. thank you why am I getting You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '7'' at line 1: Code: [Select] <?php session_start(); // Must start session first thing /* Created By Adam Khoury @ www.flashbuilding.com -----------------------June 20, 2008----------------------- */ // Here we run a login check if (!isset($_SESSION['id'])) { echo 'Please <a href="login.php">log in</a> to access your account'; exit(); } //Connect to the database through our include include_once "connect_to_mysql.php"; // Place Session variable 'id' into local variable $id=$_SESSION['id']; // Process the form if it is submitted if ($_POST['startdate']) { $event = $_POST['event']; $startdate = $_POST['startdate']; $enddate = $_POST['enddate']; $description = $_POST['description']; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; $subevent5 = $row['subevent5']; $subevent6 = $row['subevent6']; $subevent7 = $row['subevent7']; $subevent8 = $row['subevent8']; $title1 = $row['title1']; $title2 = $row['title2']; $title3 = $row['title3']; $title4 = $row['title4']; $title5 = $row['title5']; $title6 = $row['title6']; $title7 = $row['title7']; $title8 = $row['title8']; $price1 = $row['price1']; $price2 = $row['price2']; $price3 = $row['price3']; $price4 = $row['price4']; $price5 = $row['price5']; $price6 = $row['price6']; $price7 = $row['price7']; $price8 = $row['price8']; $sql = mysql_query("UPDATE Registration SET event='$event', startdate='$startdate', enddate='$enddate', description='$description', subevent1='$subevent1', subevent2='$subevent2', subevent3='$subevent3', subevent4=$subevent4', subevent5='$subevent5', subevent6='$subevent6', subevent7='$subevent7', subevent8='$subevent8', title1='$title1', title2='$title2', title3='$title3', title4='$title4', title5='$title5', title6='$title6', title7='$title7', title8='$title8', price1='$price1', price2='$price2', price3='$price3', price4='$price4', price5='$price5', price6='$price6', price7='$price7', price8='$price8', id='$id'") or die (mysql_error()); printf("Records updated: %d\n", mysql_affected_rows()); exit(); } // close if post ?> Hi2all! I have one question: A have this page: http://proximabih.com/elitesecurity/test_mapa.html Its on my native lang, but what is important that at the bottom of page is generated google maps static image of dynamic map. Now - how to send, or how to integrate this image to php $body of ph contact form. My idea is to have two pages-first is above link, another is php contact form, so if we have php contact form, on first page maby i need to create SUBMIT button which will by code automaticly put url with poicture in contact form body. I really don have any idea, any help is very appriciate ) Along the same lines as a "Thank you for you submission" message, is there a simple way to echo the CHANGES made to a record AFTER it has been UPDATED. For example: You have added 2 skirts and 1 shirt to your order OR You're order has been reduced by 2 pair of socks. This would compare what was stored with the change. Alternately, is there a way to show a message that ONLY addresses the values that have CHANGED as a result of the UPDATE. Example: You have altered the quantity of the following items: dresses, hats, gloves. Code: [Select] <?php include 'header.php'; ?> <form name="form1" method="post" action="insert_ac.php"> <table id="formcss" width="100%" border="0" cellspacing="1" cellpadding="3" align="center"> <tr> <td colspan="3"><strong>Insert Data Into mySQL Database </strong></td> </tr> <tr> <td width="71">Name</td> <td width="6">:</td> <td width="301"><input name="name" type="text" id="name"></td> </tr> <tr> <td>Company</td> <td>:</td> <td><input name="company" type="text" id="company"></td> </tr> <tr> <td>Phone</td> <td>:</td> <td><input name="phone" type="text" id="phone"></td> </tr> <tr> <td>Mobile</td> <td>:</td> <td><input name="mobile" type="text" id="mobile"></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td>Called</td> <td>:</td> <td><input type="checkbox" name="call" value="training" /> Training <input type="checkbox" name="call" value="business" /> Business <input type="checkbox" name="call" value="legal" /> Legal <input type="checkbox" name="call" value="other" /> Other</td> </tr> </tr> <tr> <td>Patched To</td> <td>:</td> <td> <select name="patch"> <option value="sperkins">S.Perkins</option> <option value="srayson">S.Rayson</option> <option value="strandafil">S.Trandafil</option> <option value="tmoore">T.Moore</option> <option value="lharding">L.Harding</option> <option value="vmitchell">V.Mitchell</option> <option value="achilvers">A.Chilvers</option> <option value="aedwards">A.Edwards</option> <option value="rfrost">R.Frost</option> <option value="ohoogenhout">O.Hoogenhout</option> <option value="pkeily">P.Keily</option> </select> </td> </tr> <tr> <td>Filled out by</td> <td>:</td> <td><input name="user" type="text" id="user"></td> </tr> <tr> <td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> <?php include 'footer.php'; ?> Code: [Select] <?php $host="Localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="members"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Get values from form $name=$_POST['name']; $company=$_POST['company']; $phone=$_POST['phone']; $mobile=$_POST['mobile']; $email=$_POST['email']; $call=$_POST['call']; $patch=$_POST['patch']; $user=$_POST['user']; // Insert data into mysql $sql="INSERT INTO $tbl_name(name, company, phone, mobile, email, call, patch, user)VALUES('$name', '$company', '$phone' '$mobile', '$email', '$call', '$patch', '$user')"; $result=mysql_query($sql); // if successfully insert data into database, displays message "Successful". if($result){ echo "Successful"; echo "<BR>"; echo "<a href='insert.php'>Back to main page</a>"; } else { echo "ERROR 1"; //This is where the error is. Not sure why it's not working } // close connection mysql_close(); ?> Can anyone see what i've done wrong here? I swear my brain is going to explode if i look over this one more time. Just a simple form trying to submit to the database Hi I would like to add a 'welcome message' (Hello John Doe, etc.) after successful login. Can this be done best in php? Cheers, visitor I am looking for someone that would be willing to provide the code for a message box that will popup after a PHP file upload completes. It will simply display a message stating that the upload is complete. Thank you in advance for your assistance. |