Jump to content

Archived

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

JackJack

Old News

Recommended Posts

I have a php which you can update the name of your company.
It works fine except one problem, It shows the old name is the text box and at the bottom it says
"Your in the company 'old name'." Until you refresh it. If i have a refresh it i wont be able to see
You have successfully updayed your company name.
Please Help

[code]
<? include ("header.php"); ?>
<?
$name = $_POST['name'];
$tim = time();
?>
<?php
    $companys = mysql_fetch_array(mysql_query("SELECT * FROM `companys` WHERE `name`='$stat[company_name]'"));
?>
<?
if($stat[company_status] == 0){
?>
Your not in a company at the moment.<br>
Click <a href="district" target="_self">here</a> to join or create a company.
<? }else{ ?>
<?
if($companys[owner] == $stat[display_name]){
?>
<center>
  <h2><u>Change Your Companys Settings</u></h2>
</center><br>

<form name="updatename" method="post" action="company.php?update=name">
<table width="29%" border="2" cellspacing="1" cellpadding="1">
  <tr>
    <th width="53%" bgcolor="#CCCCCC" scope="row">Company Name : </th>
    <td width="47%">
      <div align="center">
        <input name="name" type="text" value="<? echo $companys['name']; ?>" size="20" maxlength="15">
        </div></td>
  </tr>
</table>
<table width="30%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th height="12" scope="row"><input type="submit" name="Submit2" value="Update"></th>
  </tr>
</table>
</form><br>
<?
if($update == 'name'){
?>
<?php
    $dupe0 = mysql_num_rows(mysql_query("select * from companys where name='$name'"));

    if ($dupe0 > 0) {
?>
There is already a company with that name.
<? }else{ ?>
<?
mysql_query("UPDATE `company_news` SET `company`='$name' WHERE `owner`='$stat[display_name]'");
mysql_query("UPDATE `companys` SET `name`='$name' WHERE `owner`='$stat[display_name]'");
mysql_query("UPDATE `company_news` SET `company`='$name' WHERE `company`='$company[name]'");
mysql_query("UPDATE `players` SET `company_name`='$name' WHERE `id`='$stat[id]'");
mysql_query("INSERT INTO `company_news` (sender, title, message, company, owner) VALUES ('Updater','Company Name Updated','Your companys name has been updated to $name.','$name','$stat[display_name]')") or die(mysql_error());
echo "You successfully changed your companys name to <b>$name</b>.";
} } ?>

  <? }else{ ?>

<center>
  <h2><u>View Your Companys Settings</u></h2>
</center>
Your a member.
<? } ?>
<br>
Your in the company <b><? echo $stat[company_name]; ?></b>.
<? } ?>
[/code]


Thank you

Ps. I know my codings terebaly untidy. Ill sort it out myself when im finished though.

Share this post


Link to post
Share on other sites

×

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.