•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,509 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,163 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 193 | Replies: 7 | Solved
![]() |
•
•
Join Date: Jun 2008
Location: hyderabad,india
Posts: 109
Reputation:
Rep Power: 1
Solved Threads: 13
hi all,
i created a shoutbox where users will display messages. when they click on shoutbox a table will appear in which we have message and name when they submit messages it should appear beside that shoutbox
shoutbox hiii hyderabad:praveen :: hello praveen:pandu
like this,i have inserted messages and names into database and i have to retrieve them in same page the problem its not coming and error is displayed saying program is not responding
i want to display that message without refreshing the page
please help me thank u in advance
i created a shoutbox where users will display messages. when they click on shoutbox a table will appear in which we have message and name when they submit messages it should appear beside that shoutbox
shoutbox hiii hyderabad:praveen :: hello praveen:pandu
like this,i have inserted messages and names into database and i have to retrieve them in same page the problem its not coming and error is displayed saying program is not responding
i want to display that message without refreshing the page
please help me thank u in advance
Failure is success if we learn from it
•
•
Join Date: Jul 2008
Location: Sweet India
Posts: 828
Reputation:
Rep Power: 2
Solved Threads: 74
Try this..
it works fine:
it works fine:
php Syntax (Toggle Plain Text)
<? mysql_connect('localhost','root','1234'); mysql_select_db('banjarahills'); if($_SERVER['REQUEST_METHOD']=='POST'){ print_r($_POST); $n=$_POST['name']; $m=$_POST['message']; } if(isset($_POST['submit'])) { $message=$_POST['message']; $name=$_POST['name']; if(strlen($message)<1) { print "You did not type amessage."; //no name entered } else if(strlen($name)<1) { print "You did not type name."; //no post entered } else { $thedate=date("U"); //get unix timestamp $displaytime=date("F j, Y, g:i a"); //we now strip HTML injections $message=strip_tags($message); $name=strip_tags($name); $insertpost="INSERT INTO shout (message,name) values('$message','$name')"; mysql_query($insertpost) or die("Could not insert post"); } } $res="select * from shout"; $res1=mysql_query($res); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <script language="javascript"> function toggle_it(itemID){ // Toggle visibility between none and inline if ((document.getElementById(itemID).style.display == 'none')) { document.getElementById(itemID).style.display = 'inline'; } else { document.getElementById(itemID).style.display = 'none'; } } </script> <body> <form action="" name="form1" method="post"> <table width="981" height="57" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="155"><a href="#" onClick="toggle_it('prl')">shoutbox</a></td> <td width="826"> <marquee direction="left"> <? if(isset($_POST['submit'])) { while($res2=mysql_fetch_array($res1)) { ?> <?=$res2['message'];?>:<?=$res2['name'];?><? }}?></marquee> </td> </tr> <table width="291" id="prl" style="display:none"> <tr> <td width="95">message</td> <td width="196"><input name="message" type="text" id="message" ></td> </tr> <tr> <td>name</td> <td><input name="name" type="text" id="name"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="submit" value="submit"></td> </tr> </table> </table> </form> </body> </html>
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
hai praveen ,
here i am giving u code using javascript , u can usse it if u like...........
<HTML>
<HEAD>
<SCRIPT LANGUAGE="javascript">
function CreateMsg() {
var MsgDOM = document.getElementById("MSG");
MsgDOM.innerHTML = "Hello, " + document.forms[0].FNAME.value + " " + document.forms[0].LNAME.value + ". You're sex is " + document.forms[0].GENDER.value;
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="DUH">
<INPUT TYPE=TEXT NAME=FNAME>
<INPUT TYPE=TEXT NAME=LNAME>
<SELECT NAME="GENDER">
<OPTION VALUE="Male">Male</OPTION>
<OPTION VALUE="Female">Female</OPTION>
</SELECT>
<BR><BR>
<A HREF="javascript:CreateMsg();">Create Message</A>
<BR><BR>
<SPAN ID="MSG"> </SPAN>
</FORM>
</BODY>
</HTML>
here i am giving u code using javascript , u can usse it if u like...........
<HTML>
<HEAD>
<SCRIPT LANGUAGE="javascript">
function CreateMsg() {
var MsgDOM = document.getElementById("MSG");
MsgDOM.innerHTML = "Hello, " + document.forms[0].FNAME.value + " " + document.forms[0].LNAME.value + ". You're sex is " + document.forms[0].GENDER.value;
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="DUH">
<INPUT TYPE=TEXT NAME=FNAME>
<INPUT TYPE=TEXT NAME=LNAME>
<SELECT NAME="GENDER">
<OPTION VALUE="Male">Male</OPTION>
<OPTION VALUE="Female">Female</OPTION>
</SELECT>
<BR><BR>
<A HREF="javascript:CreateMsg();">Create Message</A>
<BR><BR>
<SPAN ID="MSG"> </SPAN>
</FORM>
</BODY>
</HTML>
•
•
Join Date: Jul 2008
Location: Sweet India
Posts: 828
Reputation:
Rep Power: 2
Solved Threads: 74
Try this..
it works fine:
it works fine:
php Syntax (Toggle Plain Text)
<? mysql_connect('localhost','root','1234'); mysql_select_db('banjarahills'); if($_SERVER['REQUEST_METHOD']=='POST'){ print_r($_POST); $n=$_POST['name']; $m=$_POST['message']; } if(isset($_POST['submit'])) { $message=$_POST['message']; $name=$_POST['name']; if(strlen($message)<1) { print "You did not type amessage."; //no name entered } else if(strlen($name)<1) { print "You did not type name."; //no post entered } else { $thedate=date("U"); //get unix timestamp $displaytime=date("F j, Y, g:i a"); //we now strip HTML injections $message=strip_tags($message); $name=strip_tags($name); $insertpost="INSERT INTO shout (message,name) values('$message','$name')"; mysql_query($insertpost) or die("Could not insert post"); } } $res="select * from shout"; $res1=mysql_query($res); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <script language="javascript"> function toggle_it(itemID){ // Toggle visibility between none and inline if ((document.getElementById(itemID).style.display == 'none')) { document.getElementById(itemID).style.display = 'inline'; } else { document.getElementById(itemID).style.display = 'none'; } } </script> <body> <form action="" name="form1" method="post"> <table width="981" height="57" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="155"><a href="#" onClick="toggle_it('prl')">shoutbox</a></td> <td width="826"> <marquee direction="left"> <? if(isset($_POST['submit'])) { while($res2=mysql_fetch_array($res1)) { ?> <?=$res2['message'];?>:<?=$res2['name'];?><? }}?></marquee> </td> </tr> <table width="291" id="prl" style="display:none"> <tr> <td width="95">message</td> <td width="196"><input name="message" type="text" id="message" ></td> </tr> <tr> <td>name</td> <td><input name="name" type="text" id="name"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="submit" value="submit"></td> </tr> </table> </table> </form> </body> </html>
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
•
•
Join Date: Jun 2008
Location: hyderabad,india
Posts: 109
Reputation:
Rep Power: 1
Solved Threads: 13
•
•
Join Date: Jul 2008
Location: Sweet India
Posts: 828
Reputation:
Rep Power: 2
Solved Threads: 74
•
•
Join Date: Jun 2008
Location: hyderabad,india
Posts: 109
Reputation:
Rep Power: 1
Solved Threads: 13
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Harddrive failure and 100% CPU under Win2K, Help Needed! (Windows NT / 2000 / XP / 2003)
- XP PRO iis help needed (Windows NT / 2000 / XP / 2003)
- CWS. help needed (Viruses, Spyware and other Nasties)
- are all these needed (Windows NT / 2000 / XP / 2003)
- help much needed !! (OS X)
Other Threads in the PHP Forum
- Previous Thread: API for Product Information
- Next Thread: upload and download file


Linear Mode