Announcement

Collapse
No announcement yet.

Help inserting username into database

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help inserting username into database

    I have a project i'm working on in which I have a timeslip database setup for cars. I need to find a way for my form to automatically grab the users name on the forums and place that in the "DRIVER" field of the form and submit it to the database so it shows the persons username when they view the timeslips. Here is my code for the addtimeslip.php page.

    PHP Code:
      <?php
    require('./global.php');
    include (
    "mainfile.php"); 
    $index 1;
    global 
    $menu_id,$menu,$Pmenu,$activeusers;
    $Pmenu="P_thememenu_homepage";
    include(
    "header.php");
    ?>
    <body bgcolor="c9cace" text="000000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"><center>
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#333D4D" width="100%">
        <tr>
          <td width="100%">
    <div align="center">
      <center>
          </center>
    </div>
    <div align="center">
      <center>
          </center>
    </div>
    <div align="center">
      <center>
          </center>
    </div>
    <div align="center">
      <center>
      <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber4" background="/vbulletin/images/bg.jpg">
        <tr>
          <td width="100%" align="center" valign="top" bgcolor="ececec">
    <?php 
    $dbh
    =mysql_connect ("localhost""sxxx_admin""xxxxxxxx") or die ('I cannot connect to the database.');
    mysql_select_db ("xxxxxx_forums"); 
    if(
    $submit == "submit")

    $sql "INSERT INTO TIMESLIPS (DRIVER,MAKE,MODEL,YEAR,INDUCTION,ET,TRAP,LOCATION) 
    VALUES ('
    $DRIVER','$MAKE','$MODEL','$YEAR','$INDUCTION','$ET','$TRAP','$LOCATION')";     
    $result mysql_query($sql); 
    if (!
    $sql) { 
    echo 
    mysql_error(); 
    }
    echo
    "<META HTTP-EQUIV='refresh' content='0;URL=http://www.mysite.com/vbulletin/TIMESLIP.php'>";

    Else 

    ?> 
    <form method=post action='<?php echo $PHP_SELF?>'>
              <p>
    </p>
              <table width="100%" border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
                <tr> 
                  <td colspan="6"><div align="center"><font color="000000" size="2" face="Arial, Helvetica, sans-serif"> 
                      </font></div>
                    <div align="center"><font color="000000" size="2" face="Arial, Helvetica, sans-serif"><strong>User 
                      Name:</strong> 
                      <?php 
         
    echo("<a href=\"member.php?s=$session[sessionhash]&action=getinfo&userid=$bbuserinfo[userid]\">$bbuserinfo[username]</a>"); 
    ?>
                      <input name="DRIVER" type="hidden">
                      </font></div>
                    <div align="center"><font face="Arial, Helvetica, sans-serif"><font size="1"><font size="2"></font></font></font></div></td>
                </tr>
                <tr> 
                  <td width="16%" valign="middle"> <div align="right"><strong><font color="000000" size="2" face="Arial, Helvetica, sans-serif"><br>
                      Make: </font></strong></div></td>
                  <td width="16%" align="left" valign="bottom"> <div align="left"><font color="000000" size="2" face="Arial, Helvetica, sans-serif"> 
                      <select name="MAKE" size="1" id="select7">
                        <option>Acura</option>
                        <option>Audi</option>
                        <option>BMW</option>
                        <option>Chevrolet</option>
                        <option>Dodge</option>
                        <option>Ford</option>
                        <option>Honda</option>
                        <option>Lexus</option>
                        <option>Mazda</option>
                        <option>Mercedes</option>
                        <option>MINI</option>
                        <option>Mitsubishi</option>
                        <option>Nissan</option>
                        <option>Porsche</option>
                        <option>Saab</option>
                        <option>Subaru</option>
                        <option>Toyota</option>
                        <option>Volkswagen</option>
                        <option>Volvo</option>
                      </select>
                      </font></div></td>
                  <td width="16%" valign="middle"> <div align="right"><strong><font color="000000" size="2" face="Arial, Helvetica, sans-serif"><br>
                      Model: </font></strong></div></td>
                  <td width="19%" valign="bottom"><div align="left"><font color="000000" size="2" face="Arial, Helvetica, sans-serif"> 
                      <input type=Text name='MODEL' >
                      </font></div></td>
                  <td width="16%" valign="middle"> <div align="right"><strong><font color="000000" size="2" face="Arial, Helvetica, sans-serif"><br>
                      Year: </font></strong></div></td>
                  <td width="16%" valign="bottom"><div align="left"><font color="000000" size="2" face="Arial, Helvetica, sans-serif"> 
                      <select name="YEAR" size="1" id="select9">
                        <option>1980</option>
                        <option>1981</option>
                        <option>1982</option>
                        <option>1983</option>
                        <option>1984</option>
                        <option>1985</option>
                        <option>1986</option>
                        <option>1987</option>
                        <option>1988</option>
                        <option>1989</option>
                        <option>1990</option>
                        <option>1991</option>
                        <option>1992</option>
                        <option>1993</option>
                        <option>1994</option>
                        <option>1995</option>
                        <option>1996</option>
                        <option>1997</option>
                        <option>1998</option>
                        <option>1999</option>
                        <option>2000</option>
                        <option>2001</option>
                        <option>2002</option>
                        <option>2003</option>
                        <option>2004</option>
                        <option>2005</option>
                        <option>2006</option>
                        <option>2007</option>
                        <option>2008</option>
                        <option>2009</option>
                        <option>2010</option>
                      </select>
                      </font></div></td>
                </tr>
                <tr> 
                  <td valign="middle"> <div align="right"><strong><font color="000000" size="2" face="Arial, Helvetica, sans-serif"><br>
                      Power Adder: </font></strong></div></td>
                  <td align="left" valign="bottom"> <div align="left"><font color="000000" size="2" face="Arial, Helvetica, sans-serif"> 
                      <select name="INDUCTION" size="1" id="select8">
                        <option>N/A</option>
                        <option>Turbocharged</option>
                        <option>Supercharged</option>
                        <option>Nitrous Oxide</option>
                        <option>Other</option>
                      </select>
                      </font></div></td>
                  <td valign="middle"> <div align="right"><strong><font color="000000" size="2" face="Arial, Helvetica, sans-serif"><br>
                      ET: </font></strong></div></td>
                  <td valign="bottom"><div align="left"><font color="000000" size="2" face="Arial, Helvetica, sans-serif"> 
                      <select name="ET" size="1" id="select10">
                        <option>9.00</option>
                        <option>9.10</option>
                        <option>9.20</option>
                        <option>9.30</option>
                        <option>9.40</option>
                        <option>9.50</option>
                        <option>9.60</option>
                        <option>9.70</option>
                        <option>9.80</option>
                        <option>9.90</option>
                        <option>10.00</option>
                        <option>10.10</option>
                        <option>10.20</option>
                        <option>10.30</option>
                        <option>10.40</option>
                        <option>10.50</option>
                        <option>10.60</option>
                        <option>10.70</option>
                        <option>10.80</option>
                        <option>10.90</option>
                        <option>11.00</option>
                        <option>11.10</option>
                        <option>11.20</option>
                        <option>11.30</option>
                        <option>11.40</option>
                        <option>11.50</option>
                        <option>11.60</option>
                        <option>11.70</option>
                        <option>11.80</option>
                        <option>11.90</option>
                        <option>12.00</option>
                        <option>12.10</option>
                        <option>12.20</option>
                        <option>12.30</option>
                        <option>12.40</option>
                        <option>12.50</option>
                        <option>12.60</option>
                        <option>12.70</option>
                        <option>12.80</option>
                        <option>12.90</option>
                        <option>13.00</option>
                        <option>13.10</option>
                        <option>13.20</option>
                        <option>13.30</option>
                        <option>13.40</option>
                        <option>13.50</option>
                        <option>13.60</option>
                        <option>13.70</option>
                        <option>13.80</option>
                        <option>13.90</option>
                        <option>14.00</option>
                        <option>14.10</option>
                        <option>14.20</option>
                        <option>14.30</option>
                        <option>14.40</option>
                        <option>14.50</option>
                        <option>14.60</option>
                        <option>14.70</option>
                        <option>14.80</option>
                        <option>14.90</option>
                        <option>15.00</option>
                        <option>15.10</option>
                        <option>15.20</option>
                        <option>15.30</option>
                        <option>15.40</option>
                        <option>15.50</option>
                        <option>15.60</option>
                        <option>15.70</option>
                        <option>15.80</option>
                        <option>15.90</option>
                        <option>16.00</option>
                        <option>16.10</option>
                        <option>16.20</option>
                        <option>16.30</option>
                        <option>16.40</option>
                        <option>16.50</option>
                        <option>16.60</option>
                        <option>16.70</option>
                        <option>16.80</option>
                        <option>16.90</option>
                        <option>17.00</option>
                        <option>17.10</option>
                        <option>17.20</option>
                        <option>17.30</option>
                        <option>17.40</option>
                        <option>17.50</option>
                        <option>17.60</option>
                        <option>17.70</option>
                        <option>17.80</option>
                        <option>17.90</option>
                        <option>18.00</option>
                      </select>
                      </font></div></td>
                  <td valign="middle"> <div align="right"><strong><font color="000000" size="2" face="Arial, Helvetica, sans-serif"><br>
                      Trap Speed: </font></strong></div></td>
                  <td valign="bottom"><div align="left"><font color="000000" size="2" face="Arial, Helvetica, sans-serif"> 
                      <select name="TRAP" size="1" id="select11">
                        <option>70</option>
                        <option>71</option>
                        <option>72</option>
                        <option>73</option>
                        <option>74</option>
                        <option>75</option>
                        <option>76</option>
                        <option>77</option>
                        <option>78</option>
                        <option>79</option>
                        <option>80</option>
                        <option>81</option>
                        <option>82</option>
                        <option>83</option>
                        <option>84</option>
                        <option>85</option>
                        <option>86</option>
                        <option>87</option>
                        <option>88</option>
                        <option>89</option>
                        <option>90</option>
                        <option>91</option>
                        <option>92</option>
                        <option>93</option>
                        <option>94</option>
                        <option>95</option>
                        <option>96</option>
                        <option>97</option>
                        <option>98</option>
                        <option>99</option>
                        <option>100</option>
                        <option>101</option>
                        <option>102</option>
                        <option>103</option>
                        <option>104</option>
                        <option>105</option>
                        <option>106</option>
                        <option>107</option>
                        <option>108</option>
                        <option>109</option>
                        <option>110</option>
                        <option>111</option>
                        <option>112</option>
                        <option>113</option>
                        <option>114</option>
                        <option>115</option>
                        <option>116</option>
                        <option>117</option>
                        <option>118</option>
                        <option>119</option>
                        <option>120</option>
                        <option>121</option>
                        <option>122</option>
                        <option>123</option>
                        <option>124</option>
                        <option>125</option>
                        <option>126</option>
                        <option>127</option>
                        <option>128</option>
                        <option>129</option>
                        <option>130</option>
                        <option>131</option>
                        <option>132</option>
                        <option>133</option>
                        <option>134</option>
                        <option>135</option>
                        <option>136</option>
                        <option>137</option>
                        <option>138</option>
                        <option>139</option>
                        <option>140</option>
                        <option>141</option>
                        <option>142</option>
                        <option>143</option>
                        <option>144</option>
                        <option>145</option>
                        <option>146</option>
                        <option>147</option>
                        <option>148</option>
                        <option>149</option>
                        <option>150</option>
                        <option>151</option>
                        <option>152</option>
                        <option>153</option>
                        <option>154</option>
                        <option>155</option>
                        <option>156</option>
                        <option>157</option>
                        <option>158</option>
                        <option>159</option>
                        <option>160</option>
                        <option>161</option>
                        <option>162</option>
                        <option>163</option>
                        <option>164</option>
                        <option>165</option>
                        <option>166</option>
                        <option>167</option>
                        <option>168</option>
                        <option>169</option>
                        <option>170</option>
                      </select>
                      </font></div></td>
                </tr>
                <tr> 
                  <td colspan="3"><div align="center"><font face="Arial, Helvetica, sans-serif"><font size="1"><font size="2"></font></font></font></div>
                    <div align="right"><strong><font color="000000" size="2" face="Arial, Helvetica, sans-serif"><br>
                      Location: </font></strong></div></td>
                  <td colspan="3" valign="bottom"><div align="left"><font color="000000" size="2" face="Arial, Helvetica, sans-serif"> 
                      <select name="LOCATION" size="1" id="select12">
                        <option>AL</option>
                        <option>AK</option>
                        <option>AZ</option>
                        <option>AR</option>
                        <option>CA</option>
                        <option>CO</option>
                        <option>CT</option>
                        <option>DE</option>
                        <option>FL</option>
                        <option>GA</option>
                        <option>HI</option>
                        <option>ID</option>
                        <option>IL</option>
                        <option>IN</option>
                        <option>IA</option>
                        <option>KS</option>
                        <option>KY</option>
                        <option>LA</option>
                        <option>ME</option>
                        <option>MD</option>
                        <option>MA</option>
                        <option>MI</option>
                        <option>MN</option>
                        <option>MS</option>
                        <option>MO</option>
                        <option>MT</option>
                        <option>NE</option>
                        <option>NV</option>
                        <option>NH</option>
                        <option>NJ</option>
                        <option>NM</option>
                        <option>NY</option>
                        <option>NC</option>
                        <option>ND</option>
                        <option>OH</option>
                        <option>OK</option>
                        <option>OR</option>
                        <option>PA</option>
                        <option>RI</option>
                        <option>SC</option>
                        <option>SD</option>
                        <option>TN</option>
                        <option>TX</option>
                        <option>UT</option>
                        <option>VT</option>
                        <option>VA</option>
                        <option>WA</option>
                        <option>WV</option>
                        <option>WI</option>
                        <option>WY</option>
                        <option>NON U.S.</option>
                      </select>
                      </font></div>
                    <div align="center"><font face="Arial, Helvetica, sans-serif"><font size="1"><font size="2"></font></font></font></div></td>
                </tr>
                <tr> 
                  <td height="35" colspan="6"> <div align="center"><font face="Arial, Helvetica, sans-serif"><font size="1"><font size="2"></font></font></font></div>
                    <div align="center"> <font size="2" face="Arial, Helvetica, sans-serif"> 
                      <input type=submit name=submit value=submit>
                      </font></div>
                    <div align="center"><font face="Arial, Helvetica, sans-serif"><font size="1"><font size="2"></font></font></font></div></td>
                </tr>
              </table>
              <p><font color="000000"><br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
                </font><br>
              </p>
    </form>
    <? 

    ?> 
    <?php
    echo "<br>"
    include(
    "footer.php");
    ?>

  • #2
    I assume thats vB's global.php your requiring, if so then set the value of the field to $bbuserinfo[username] which will contain the current users forum username.
    vBulletin.org Moderator
    The Sisters Three Charmed Discussion Forums

    Comment


    • #3
      All that comes out in the output when I try that is the $bbuserinfo[username] variable. It doesn't showe the username. I have require global i nthe file that presents the output as well (timeslip.php). Any idea's?

      Comment


      • #4
        Ohhhh I got it to work I used
        PHP Code:
        <?php
        $var 
        "$bbuserinfo[username]"
        echo 
        "<input name=\"DRIVER\" type=\"hidden\" value=\"$var\">\n";
        ?>
        It doesn't create a link to the persons profile, but i'll work on that.

        Thanks for the lead

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        X