Jump to content

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.
Link to comment
https://forums.phpfreaks.com/topic/8172-old-news/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.