Jump to content

please help doing my head in


Danny620

Recommended Posts

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\send.php on line 37

 

<?php require('config.php'); ?>

<?php	

if(isset($_POST[send])){

		$x = array();

	$user = htmlentities($_POST[user]);
	$message = htmlentities($_POST[message]);

	$user = mysqli_real_escape_string($dbc,$user);
	$message = mysqli_real_escape_string($dbc,$message);

	$countmessage = strlen ($message);

	if($countmessage <= 2){ $x = 'Message Must be greater than 2 letters'; }

	$q = "SELECT username FROM test WHERE username='$user'";
			$r = mysqli_query($dbc,$q);
			$usercheck = mysqli_num_rows($r);

			if($usercheck != 1){ $x = 'The user does not exist'; }

	}

	?>
<link href="battle Eara/css/testting.css" rel="stylesheet" type="text/css">
<form id="form1" name="form1" method="post" action="">
  <table width="379" border="0" align="center" class="table_bottom">
    <tr class="top_table">
      <td colspan="2"><span class="style1">Create Message</span></td>
    </tr>
    <tr>
      <td width="95" height="47"> </td>
      <td width="229"><div align="center">
        <?php foreach($x as $msg){ echo " - $msg<br />"; } ?>
      </div> </td>
    </tr>
    <tr>
      <td><div align="center" class="style3">To:</div></td>
      <td><label>
        <input name="user" type="text" class="textfield" id="user" maxlength="20" />
      </label></td>
    </tr>
    <tr>
      <td height="106"><div align="center" class="style3">Message:</div></td>
      <td><label>
        <textarea name="message" cols="45" rows="5" class="textfield" id="message"></textarea>
      </label></td>
    </tr>
    <tr>
      <td height="33"> </td>
      <td><label>
        <div align="center">
          <input name="send" type="submit" class="textfield" id="send" value="Send" />
        </div>
      </label></td>
    </tr>
    <tr>
      <td height="33">Testing Zone</td>
      <td> </td>
    </tr>
  </table>
</form>

Link to comment
https://forums.phpfreaks.com/topic/172475-please-help-doing-my-head-in/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.