User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 427,939 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,792 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: 197 | Replies: 7 | Solved
Reply
Join Date: Jun 2008
Location: hyderabad,india
Posts: 110
Reputation: praveen_dusari is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 13
praveen_dusari's Avatar
praveen_dusari praveen_dusari is offline Offline
Junior Poster

help needed

  #1  
Jul 21st, 2008
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
Failure is success if we learn from it
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2008
Location: Sweet India
Posts: 849
Reputation: Shanti Chepuru is on a distinguished road 
Rep Power: 2
Solved Threads: 74
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Practically a Posting Shark

Re: help needed

  #2  
Jul 21st, 2008
Try this..
it works fine:
  1. <?
  2. mysql_connect('localhost','root','1234');
  3. mysql_select_db('banjarahills');
  4.  
  5. if($_SERVER['REQUEST_METHOD']=='POST'){
  6. print_r($_POST);
  7.  
  8. $n=$_POST['name'];
  9. $m=$_POST['message'];
  10. }
  11. if(isset($_POST['submit']))
  12. {
  13. $message=$_POST['message'];
  14.  
  15. $name=$_POST['name'];
  16.  
  17.  
  18.  
  19.  
  20.  
  21. if(strlen($message)<1)
  22.  
  23. {
  24.  
  25. print "You did not type amessage."; //no name entered
  26.  
  27. }
  28.  
  29. else if(strlen($name)<1)
  30.  
  31. {
  32.  
  33. print "You did not type name."; //no post entered
  34.  
  35. }
  36.  
  37.  
  38.  
  39. else
  40.  
  41. {
  42. $thedate=date("U"); //get unix timestamp
  43.  
  44. $displaytime=date("F j, Y, g:i a");
  45.  
  46. //we now strip HTML injections
  47. $message=strip_tags($message);
  48.  
  49. $name=strip_tags($name);
  50.  
  51.  
  52. $insertpost="INSERT INTO shout (message,name) values('$message','$name')";
  53.  
  54. mysql_query($insertpost) or die("Could not insert post");
  55. } }
  56.  
  57.  
  58.  
  59. $res="select * from shout";
  60. $res1=mysql_query($res);
  61.  
  62. ?>
  63. <html>
  64. <head>
  65. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  66. <title>Untitled Document</title>
  67. </head>
  68. <script language="javascript">
  69. function toggle_it(itemID){
  70. // Toggle visibility between none and inline
  71. if ((document.getElementById(itemID).style.display == 'none'))
  72. {
  73. document.getElementById(itemID).style.display = 'inline';
  74. } else {
  75. document.getElementById(itemID).style.display = 'none';
  76. }
  77. }
  78. </script>
  79.  
  80. <body>
  81. <form action="" name="form1" method="post">
  82. <table width="981" height="57" border="0" cellpadding="0" cellspacing="0">
  83. <tr>
  84. <td width="155"><a href="#" onClick="toggle_it('prl')">shoutbox</a></td>
  85. <td width="826">
  86. <marquee direction="left">
  87. <?
  88. if(isset($_POST['submit']))
  89. {
  90. while($res2=mysql_fetch_array($res1))
  91. {
  92. ?>
  93. <?=$res2['message'];?>:<?=$res2['name'];?><? }}?></marquee>
  94. </td>
  95. </tr>
  96. <table width="291" id="prl" style="display:none">
  97. <tr>
  98. <td width="95">message</td>
  99. <td width="196"><input name="message" type="text" id="message" ></td>
  100. </tr>
  101. <tr>
  102. <td>name</td>
  103. <td><input name="name" type="text" id="name"></td>
  104. </tr>
  105. <tr>
  106. <td colspan="2" align="center"><input type="submit" name="submit" value="submit"></td>
  107. </tr>
  108.  
  109. </table>
  110. </table>
  111. </form>
  112. </body>
  113. </html>
  114.  
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote  
Join Date: Jul 2008
Posts: 9
Reputation: us12 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 2
us12's Avatar
us12 us12 is offline Offline
Newbie Poster

Re: help needed

  #3  
Jul 21st, 2008
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">&nbsp;</SPAN>
</FORM>
</BODY>
</HTML>
Reply With Quote  
Join Date: Jul 2008
Location: Sweet India
Posts: 849
Reputation: Shanti Chepuru is on a distinguished road 
Rep Power: 2
Solved Threads: 74
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Practically a Posting Shark

Re: help needed

  #4  
Jul 21st, 2008
Try this..
it works fine:
  1. <?
  2. mysql_connect('localhost','root','1234');
  3. mysql_select_db('banjarahills');
  4.  
  5. if($_SERVER['REQUEST_METHOD']=='POST'){
  6. print_r($_POST);
  7.  
  8. $n=$_POST['name'];
  9. $m=$_POST['message'];
  10. }
  11. if(isset($_POST['submit']))
  12. {
  13. $message=$_POST['message'];
  14.  
  15. $name=$_POST['name'];
  16.  
  17.  
  18.  
  19.  
  20.  
  21. if(strlen($message)<1)
  22.  
  23. {
  24.  
  25. print "You did not type amessage."; //no name entered
  26.  
  27. }
  28.  
  29. else if(strlen($name)<1)
  30.  
  31. {
  32.  
  33. print "You did not type name."; //no post entered
  34.  
  35. }
  36.  
  37.  
  38.  
  39. else
  40.  
  41. {
  42. $thedate=date("U"); //get unix timestamp
  43.  
  44. $displaytime=date("F j, Y, g:i a");
  45.  
  46. //we now strip HTML injections
  47. $message=strip_tags($message);
  48.  
  49. $name=strip_tags($name);
  50.  
  51.  
  52. $insertpost="INSERT INTO shout (message,name) values('$message','$name')";
  53.  
  54. mysql_query($insertpost) or die("Could not insert post");
  55. } }
  56.  
  57.  
  58.  
  59. $res="select * from shout";
  60. $res1=mysql_query($res);
  61.  
  62. ?>
  63. <html>
  64. <head>
  65. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  66. <title>Untitled Document</title>
  67. </head>
  68. <script language="javascript">
  69. function toggle_it(itemID){
  70. // Toggle visibility between none and inline
  71. if ((document.getElementById(itemID).style.display == 'none'))
  72. {
  73. document.getElementById(itemID).style.display = 'inline';
  74. } else {
  75. document.getElementById(itemID).style.display = 'none';
  76. }
  77. }
  78. </script>
  79.  
  80. <body>
  81. <form action="" name="form1" method="post">
  82. <table width="981" height="57" border="0" cellpadding="0" cellspacing="0">
  83. <tr>
  84. <td width="155"><a href="#" onClick="toggle_it('prl')">shoutbox</a></td>
  85. <td width="826">
  86. <marquee direction="left">
  87. <?
  88. if(isset($_POST['submit']))
  89. {
  90. while($res2=mysql_fetch_array($res1))
  91. {
  92. ?>
  93. <?=$res2['message'];?>:<?=$res2['name'];?><? }}?></marquee>
  94. </td>
  95. </tr>
  96. <table width="291" id="prl" style="display:none">
  97. <tr>
  98. <td width="95">message</td>
  99. <td width="196"><input name="message" type="text" id="message" ></td>
  100. </tr>
  101. <tr>
  102. <td>name</td>
  103. <td><input name="name" type="text" id="name"></td>
  104. </tr>
  105. <tr>
  106. <td colspan="2" align="center"><input type="submit" name="submit" value="submit"></td>
  107. </tr>
  108.  
  109. </table>
  110. </table>
  111. </form>
  112. </body>
  113. </html>
  114.  
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote  
Join Date: Jun 2008
Location: hyderabad,india
Posts: 110
Reputation: praveen_dusari is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 13
praveen_dusari's Avatar
praveen_dusari praveen_dusari is offline Offline
Junior Poster

Re: help needed

  #5  
Jul 21st, 2008
thanx shanti and us12,
i'll try it but there is no much difference in ur code and my code shanti i will make changes in my code thank u
Failure is success if we learn from it
Reply With Quote  
Join Date: Jul 2008
Location: Sweet India
Posts: 849
Reputation: Shanti Chepuru is on a distinguished road 
Rep Power: 2
Solved Threads: 74
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Practically a Posting Shark

Re: help needed

  #6  
Jul 21st, 2008
k praveen...tel me if any error occurs...
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote  
Join Date: Jun 2008
Location: hyderabad,india
Posts: 110
Reputation: praveen_dusari is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 13
praveen_dusari's Avatar
praveen_dusari praveen_dusari is offline Offline
Junior Poster

Re: help needed

  #7  
Jul 21st, 2008
thank u
my problem is solved
Failure is success if we learn from it
Reply With Quote  
Join Date: Jul 2008
Posts: 9
Reputation: us12 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 2
us12's Avatar
us12 us12 is offline Offline
Newbie Poster

Re: help needed

  #8  
Jul 21st, 2008
hai shanthi,
Nice code yaar.........
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 6:36 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC