Jump to content

drew4663

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by drew4663

  1. I finally got it to work......thanks everyone for pointing me in the correct direction. $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $pathFragments = explode('=', $url); $end = end($pathFragments); $sql = mysql_query("select * from providers where providerID like $end"); while ($row = mysql_fetch_array($sql)){ $providerID = $row['providerID']; $provider = $row['provider']; $service = $row['service']; $phone = $row['phone']; $tier = $row['tier'];
  2. I changed this line and it is now not giving any errors but it is only pulling the last record. $sql = "select providerID, provider, service, phone, tier from providers where providerID";
  3. Yes. That is correct. This echo "<br/><a href='update.php?providerID=$row[providerID]'>Update</a>"; Produces http://mydomain.com/update.php?providerID=1 Now I have the update.php code of...... <?php mysql_connect ("localhost", "username","password") or die (mysql_error()); mysql_select_db ("dbname"); $sql = "select * from `providers` where providerID = $providerID"; $query = mysql_query($sql); while ($row = mysql_fetch_array($query)){ $providerID = $row['providerID']; $provider = $row['provider']; $service = $row['service']; $phone = $row['phone']; $tier = $row['tier']; //we will echo these into the proper fields } mysql_free_result($query); ?> <html> <head> <title>Edit User Info</title> </head> <body> <form action="updateinfo.php" method="post"> <p>provider id:<br/> <input type="text" value="<?php echo htmlentities($_GET['providerID'],ENT_QUOTES); ?>" name="providerID" disabled/> <br/> Provider:<br/> <input type="text" value="<?php echo $provider;?>" name="provider"/> <br/> Service:<br/> <input type="text" value="<?php echo $service;?>" name="service"/> <br/> Phone:<br/> <input type="text" value="<?php echo $phone;?>" name="phone"/> <br> Tier:<br/> <input type="text" value="<?php echo $tier;?>" name="tier"/> </br> <br> <br> <input type="submit" value="submit changes"/> </p> </form> </body> </html> Doing it this way does put the "providerID" in the correct field but none of the other fields populate and I still get the boolean errors because of this line not being correct. $sql = "select * from `providers` where providerID = $providerID"; Any suggestions of what I should be putting there? Should I remove the echo htmlentities($_GET['providerID'],ENT_QUOTES); and place it after WHERE?
  4. Ok, so I am now able to get the ID into the URL. Any ideas how to get it from the URL to the textbox? URL looks like.... http://mydomain.com/update.php?=1
  5. FYI - When I manually put in a number here... $sql = "select * from `providers` where ID = 3"; It works great. So, I am guessing that I am having an issue with maybe the way the records are pulled in from the search. This is my html file for my search..... search.html <html> <head> <title>Search the Database</title> <link href="search_providers.css" rel="stylesheet" type="text/css"> </head> <body> <div id="wrapper"> <form action="search.php" method="post"> <div id="providername"> <p>Search: <input type="text" name="term" /> </p> </div> <div id="providersubmit"> <p> <input type="submit" name="submit" value="Submit" /></p></div> </form> </div> </body> </html> Here is the php file for the result of the search. search.php mysql_connect ("mydomain", "username","password") or die (mysql_error()); mysql_select_db ("dbname"); $term = $_POST['term']; $sql = mysql_query("select * from providers where provider like '%$term%'"); $ID = $_GET['providerID']; while ($row = mysql_fetch_array($sql)){ echo '<br/> ProviderID: '.$row['providerID']; echo '<br/> Provider: '.$row['provider']; echo '<br/> Service: '.$row['service']; echo '<br/> Phone: '.$row['phone']; echo '<br/> Tier: '.$row['tier']; echo "<a href='update.php?providerID=$ID'>Update</a>"; So here is what the search will get me. Sometimes it will pull one record or ten depends on what you enter into the search, but I am wanting whatever records are pulled to have that update link reference that particular id and post it in the url and load it in the html form. I'm not sure if I am making myself clear or not so bare with me. Example: ProviderID: 7 Provider: AT&T - Ameritech, SW Bell, SBC, Bell South Service: DSL, T1 Phone: 888-434-6186 Tier: AT&T Advanced Technical Support Update <----link should read when mouse-hover "http://www.mydomain.com/update.php(and then the ID # 7) ProviderID: 8 Provider: AT&T - SBC Global Service: DSL Phone: 1-877-722-3755 Tier: Tier 1 - Tech Support Update <----link should read when mouse-hover "http://www.mydomain.com/update.php(and then the ID # ProviderID: 9 Provider: AT&T Bell South Service: DSL Phone: 888-321-2375 Tier: Tier 1 Update <----link should read when mouse-hover "http://www.mydomain.com/update.php(and then the ID # 9) ProviderID: 10 Provider: AT&T Service: T1 Phone: 888-613-6330 opt 2, 1, 1, 1 Tier: Tier 1 Update <----link should read when mouse-hover "http://www.mydomain.com/update.php(and then the ID # 10) After I click the update link I want the html form to load that ID and other info so that it can be edited.
  6. Thank you for your assistance. I tried.... echo "<a href='update.php?providerID=$ID'>Update</a>"; and it resulted in http://mydomain.com/update.php?providerID= I am also getting these errors..... Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /xxx/xxxx/x/xxxxxx/xxxx/xxxxx/update.php on line 10 Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in /xxx/xxxx/x/xxxxxx/xxxx/xxxxx/update.php on line 21
  7. I have a textbox that you can enter a provider name and it searches for the name and displays the results. The code I use is.... mysql_connect ("mydomain", "username","password") or die (mysql_error()); mysql_select_db ("dbname"); $term = $_POST['term']; $sql = mysql_query("select * from providers where provider like '%$term%'"); $ID = $_GET['providerID']; while ($row = mysql_fetch_array($sql)){ echo '<br/> ProviderID: '.$row['providerID']; echo '<br/> Provider: '.$row['provider']; echo '<br/> Service: '.$row['service']; echo '<br/> Phone: '.$row['phone']; echo '<br/> Tier: '.$row['tier']; echo '<a href="update.php?providerID=<?php echo $ID; ?>">Update</a>'; This is what it will give me on the page. ProviderID: 1 Provider: Comcast Service: Cable Phone: 866-511-6489 Tier: National Business Tech Support Update <----- link When I click update the URL says..... http://wwww.mydomain...php?providerID=<?php echo $ID; ?> here is the code for the update.php file <?php $ID=$_GET['providerID']; mysql_connect ("mydomain", "username","password") or die (mysql_error()); mysql_select_db ("dbname"); $sql = "select * from `providers` where ID = $ID"; $query = mysql_query($sql); while ($row = mysql_fetch_array($query)){ $providerID = $row['providerID']; $provider = $row['provider']; $service = $row['service']; $phone = $row['phone']; $tier = $row['tier']; //we will echo these into the proper fields } mysql_free_result($query); ?> <html> <head> <title>Edit User Info</title> </head> <body> <form action="updateinfo.php" method="post"> <p>provider id:<br/> <input type="text" value="<?php echo $providerID;?>" name="providerID" disabled/> <br/> Provider:<br/> <input type="text" value="<?php echo $provider;?>" name="provider"/> <br/> Service:<br/> <input type="text" value="<?php echo $service;?>" name="service"/> <br/> Phone:<br/> <input type="text" value="<?php echo $phone;?>" name="phone"/> <br> Tier:<br/> <input type="text" value="<?php echo $tier;?>" name="tier"/> </br> <br> <br> <input type="submit" value="submit changes"/> </p> </form> </body> </html> All I am trying to do is when I create a search to be able to click on update and it allow me to update that particular record via the ID. Any clues or pointers?
  8. First, I don't give enough information. Second, I give too much information. You asked for relevant code. I explained already I am inexperienced so obviously what is relevant to me is going to be different to what is relevant to you. No offense but I did narrow the problem down. I just thought it might be "relevant" to post the processes that I was using from beginning to end. If you would take the time to read you would notice that I said all of the code works except the last which is only a few lines of code and I even explained the problem I was having. So if you are unable to help me move on please. Having to deal with you when I am someone looking for help and in need is adding to the stress of my problem so I am going to move on to a more reputable site. Thanks for the attitude admin.
  9. First Page used for connecting to the database and creating a record and writing to it. This form works in wordpress. Below is the code I use. <!-- set this form to POST method and target this form to insert.php --> <style type="text/css"> <!-- .wrapper { width: 700px; background-image: url(http://ecaunderground.com/wp-content/images/yootheme/logo.png); background-position: center top; background-repeat: no-repeat; background-color: #000; color: #FFF; } .name { height: 30px; width: 700px; ; color: #FFF; padding-top: 10px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; border: thin solid #CCC; } .start { width: 700px; color: #FFF; padding-top: 10px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; border: thin solid #CCC; } .weekly_pounds_lost { width: 700px; color: #FFF; padding-top: 10px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; text-align: left; border: thin solid #CCC; } .weekly_inches_start { width: 700px; color: #FFF; padding-top: 10px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; text-align: left; border: thin solid #CCC; } .weekly_inches_lost { width: 700px; color: #FFF; padding-top: 10px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; text-align: left; } .other_info { width: 700px; color: #FFF; padding-top: 10px; padding-right: 0px; padding-bottom: 10px; padding-left: 10px; text-align: left; border: thin solid #CCC; } .space { height: 20px; width: 700px; } body { background-color: #000; } --> </style> <!--///////////////////////////////////////////////////////////////////////wrapper class////////////////////////////////////////////////////--> <div class="wrapper"> <form id="form1" name="form1" method="post" action="insert.php"> <br /> <br /> <br /> <br /> Name: <!--///////////////////////////////////////////////////////////////////////Name class////////////////////////////////////////////////////--> <div class="name"> First : <input name="FirstName" type="text" id="FirstName" /> Last : <input name="LastName" type="text" id="LastName" /> Age: <input name="Age" type="text" id="Age" size="2" maxlength="2" /> Height: <input name="Height" type="text" id="Height" size="2" maxlength="6" /> BMI: <input name="BMI" type="text" id="BMI" size="1" maxlength="2" /> </div> <div class="space"> </div> <!--///////////////////////////////////////////////////////////////////////Start class////////////////////////////////////////////////////--> Start Info: <div class="start"> Start Date: <input name="StartDate" type="text" id="StartDate" size="5" maxlength="10" /> Start Weight: <input name="StartWeight" type="text" id="StartWeight" size="2" maxlength="3" /> Goal Date: <input name="GoalDate" type="text" id="GoalDate" size="5" maxlength="10" /> Weigh-in Day: <input name="WeighInDay" type="text" id="WeighInDay" size="5" maxlength="10" /> Goal Weight: <input name="GoalWeight" type="text" id="GoalWeight" size="2" maxlength="3" /> </div> <div class="space"> </div> <!--///////////////////////////////////////////////////////////////////////weekly_pounds_lost class////////////////////////////////////////////////////--> Pounds Lost: <div class="weekly_pounds_lost"> Wk 1: <input name="Week1" type="text" id="Week1" size="1" maxlength="2" /> Wk 2: <input name="Week2" type="text" id="Week2" size="1" maxlength="2" /> Wk 3: <input name="Week3" type="text" id="Week3" size="1" maxlength="2" /> Wk 4: <input name="Week4" type="text" id="Week4" size="1" maxlength="2" /> Wk 5: <input name="Week5" type="text" id="Week5" size="1" maxlength="2" /> Wk 6: <input name="Week6" type="text" id="Week6" size="1" maxlength="2" /> Wk 7: <input name="Week7" type="text" id="Week7" size="1" maxlength="2" /> Wk 8: <input name="Week8" type="text" id="Week8" size="1" maxlength="2" /> <br /> <br /> Wk 9: <input name="Week9" type="text" id="Week9" size="1" maxlength="2" /> Wk 10: <input name="Week10" type="text" id="Week10" size="1" maxlength="2" /> Wk 11: <input name="Week11" type="text" id="Week11" size="1" maxlength="2" /> Wk 12: <input name="Week12" type="text" id="Week12" size="1" maxlength="2" /> </div> <div class="space"> </div> <!--///////////////////////////////////////////////////////////////////////inches_start class////////////////////////////////////////////////////--> Inches at Start: <div class="weekly_inches_start"> Neck: <input name="NeckStart" type="text" id="NeckStart" size="2" maxlength="2" /> Chest: <input name="ChestStart" type="text" id="ChestStart" size="2" maxlength="2" /> Stomach: <input name="StomachStart" type="text" id="StomachStart" size="2" maxlength="2" /> Thighs: <input name="ThighsStart" type="text" id="ThighsStart" size="2" maxlength="2" /> Arms: <input name="ArmsStart" type="text" id="ArmsStart" size="2" maxlength="2" /> Calves: <input name="CalvesStart" type="text" id="CalvesStart" size="2" maxlength="2" /> Hips: <input name="HipsStart" type="text" id="HipsStart" size="2" maxlength="2" /> </div> <div class="space"> </div> <!--///////////////////////////////////////////////////////////////////////inches_start class////////////////////////////////////////////////////--> Inches Current: <div class="weekly_inches_start"> Neck: <input name="NeckCurrent" type="text" id="NeckCurrent" size="2" maxlength="2" /> Chest: <input name="ChestCurrent" type="text" id="ChestCurrent" size="2" maxlength="2" /> Stomach: <input name="StomachCurrent" type="text" id="StomachCurrent" size="2" maxlength="2" /> Thighs: <input name="ThighsCurrent" type="text" id="ThighsCurrent" size="2" maxlength="2" /> Chest: <input name="ChestCurrent" type="text" id="ChestCurrent" size="2" maxlength="2" /> Stomach: <input name="StomachCurrent" type="text" id="StomachCurrent" size="2" maxlength="2" /> Thighs: <input name="ThighsCurrent" type="text" id="ThighsCurrent" size="2" maxlength="2" /> <br /> <br /> Arms: <input name="ArmsCurrent" type="text" id="ArmsCurrent" size="2" maxlength="2" /> Calves: <input name="CalvesCurrent" type="text" id="CalvesCurrent" size="2" maxlength="2" /> Hips: <input name="HipsCurrent" type="text" id="HipsCurrent" size="2" maxlength="2" /> </div> <div class="space"> </div> <!--///////////////////////////////////////////////////////////////////////other_info class////////////////////////////////////////////////////--> Other Info: <div class="other_info"> Visalus Customer: <input name="VisalusCustomer" type="text" id="VisalusCustomer" size="3" maxlength="3" /> Visalus Distributor: <input name="VisalusDistributor" type="text" id="VisalusDistributor" size="3" maxlength="3" /> Challenge: <input name="Challenge" type="text" id="Challenge" size="3" maxlength="3" /> </div> <p> <input type="submit" name="Submit" value="Submit" /> </p> </form> </div> This is the code that I use to insert the data into the database. It's called by the first page above. <? // Connect database. include("connectdb.php"); // Get values from form. $FirstName=$_POST['FirstName']; $LastName=$_POST['LastName']; $StartDate=$_POST['StartDate']; $StartWeight=$_POST['StartWeight']; $WeighInDay=$_POST['WeighInDay']; $GoalDate=$_POST['GoalDate']; $GoalWeight=$_POST['GoalWeight']; $Week1=$_POST['Week1']; $Week2=$_POST['Week2']; $Week3=$_POST['Week3']; $Week4=$_POST['Week4']; $Week5=$_POST['Week5']; $Week6=$_POST['Week6']; $Week7=$_POST['Week7']; $Week8=$_POST['Week8']; $Week9=$_POST['Week9']; $Week10=$_POST['Week10']; $Week11=$_POST['Week11']; $Week12=$_POST['Week12']; $NeckStart=$_POST['NeckStart']; $ChestStart=$_POST['ChestStart']; $StomachStart=$_POST['StomachStart']; $ThighsStart=$_POST['ThighsStart']; $ArmsStart=$_POST['ArmsStart']; $CalvesStart=$_POST['CalvesStart']; $HipsStart=$_POST['HipsStart']; $NeckCurrent=$_POST['NeckCurrent']; $ChestCurrent=$_POST['ChestCurrent']; $StomachCurrent=$_POST['StomachCurrent']; $ThighsCurrent=$_POST['ThighsCurrent']; $ArmsCurrent=$_POST['ArmsCurrent']; $CalvesCurrent=$_POST['CalvesCurrent']; $HipsCurrent=$_POST['HipsCurrent']; $VisalusCustomer=$_POST['VisalusCustomer']; $VisalusDistributor=$_POST['VisalusDistributor']; $Challenge=$_POST['Challenge']; $Age=$_POST['Age']; $Height=$_POST['Height']; $BMI=$_POST['BMI']; // Insert all parameters into database. // The id field is auto increment. You don't have to insert any value mysql_query("insert into memberstats(FirstName, LastName, StartDate, StartWeight, WeighInDay, GoalDate, GoalWeight, Week1, Week2, Week3, Week4, Week5, Week6, Week7, Week8, Week9, Week10, Week11, Week12, NeckStart, ChestStart, StomachStart, ThighsStart, ArmsStart, CalvesStart, HipsStart, NeckCurrent, ChestCurrent, StomachCurrent, ThighsCurrent, ArmsCurrent, CalvesCurrent, HipsCurrent, VisalusCustomer, VisalusDistributor, Challenge, Age, Height, BMI) values('$FirstName', '$LastName', '$StartDate', '$StartWeight', '$WeighInDay', '$GoalDate', '$GoalWeight', '$Week1', '$Week2', '$Week3', '$Week4', '$Week5', '$Week6', '$Week7', '$Week8', '$Week9', '$Week10', '$Week11', '$Week12', '$NeckStart', '$ChestStart', '$StomachStart', '$ThighsStart', '$ArmsStart', '$CalvesStart', '$HipsStart', '$NeckCurrent', '$ChestCurrent', '$StomachCurrent', '$ThighsCurrent', '$ArmsCurrent', '$CalvesCurrent', '$HipsCurrent', '$VisalusCustomer', '$VisalusDistributor', '$Challenge', '$Age', '$Height', '$BMI')"); // Close database connection mysql_close(); header("location:http://www.ecaunderground.com/"); ?> This code gives me the opportunity to load a record and display text of a particular field(s). It gives a link for updating and snags the id putting it into the url. This works inside wordpress as well. <? // Connect database include("connectdb.php"); // Get all records in all columns from table and put it in $result. $result=mysql_query("select * from memberstats"); /*Split records in $result by table rows and put them in $row. Make it looping by while statement. */ while($row=mysql_fetch_assoc($result)){ // Output echo "id : $row[id] <br/>"; echo "FirstName : $row[FirstName] <br/>"; echo "LastName : $row[LastName] <br/>"; echo "GoalWeight : $row[GoalWeight] <br/>"; // Add a link with a parameter(id) and it's value. echo '<a href="http://ecaunderground.com/update.php?id='.$row['id'].'">Update</a>'; } mysql_close(); ?> After clicking the link the update.php is loaded and displays the html form but doesn't load any data. It's weird that all of the other php is fine but not this. I'm not sure if it has something to do with the location or not but here is the code. <? // START PHP CODES. THIS PART MUST ON THE TOP OF THIS PAGE. // Connect database. include("connectdb.php"); // ***** This part will process when you Click on "Submit" button ***** // Check, if you clicked "Submit" button if($_POST['Submit']){ // Get parameters from form. $id=$_POST['id']; $FirstName=$_POST['FirstName']; $LastName=$_POST['LastName']; $GoalWeight=$_POST['GoalWeight']; // Do update statement. mysql_query("update memberstats set FirstName='$FirstName', LastName='$LastName', GoalWeight='$GoalWeight' where id='$id'"); // Re-direct this page to select.php. header("location:select.php"); exit; } // ************* End update part ************* // *** Select data to show on text fields in form. *** // Get id parameter (GET method) from select.php $id=$_GET['id']; // Get records in all columns from table where column id equal in $id and put it in $result. $result=mysql_query("select * from memberstats where id='$id'"); // Split records in $result by table rows and put them in $row. $row=mysql_fetch_assoc($result); // Close database connection. mysql_close(); ?> <!-- END OF PHP CODES AND START HTML TAGS --> <html> <body> <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>"> <p> ID : <input name="id" type="text" id="id" value="<? echo $row['id']; ?>"/> <br /> First Name : <input name="FirstName" type="text" id="FirstName" value="<? echo $row['FirstName']; ?>"/> <br /> Last Name : <input name="LastName" type="text" id="LastName" value="<? echo $row['LastName']; ?>"/> <br /> Goal Weight : <input name="GoalWeight" type="text" id="GoalWeight" value="<? echo $row['GoalWeight']; ?>"/> </p> <p> <input type="submit" name="Submit" value="Submit" /> </p> </form> </body> </html> This is all the code involved. Like I said before, it works outside of wordpress but the update does not. I think it has something to do with the url but don't know how to troubleshoot it. Let me know if you need anything else. As of right now the wordpress pages I have this code in are private pages but can temporarily allow them to be seen if it will help. Thanks. Andrew
  10. I have a php tutorial that I followed for creating, inserting, selecting and updating a MySQL database with php. Everything works fine so I wanted to put it into Wordpress. I took the code and placed it into the wordpress page and everything worked just fine except the update function. Here is the tutorial I used. http://www.phpsimple.net/mysql_insert_record.html It is also the part I am having trouble with. I am able to create a record and I am also able to select a record but when I choose "update" the form doesn't load the data. It will outside the website but not inside wordpress. I am hoping this is not vague but because of my inexperience I am not sure what else to say. I will be more than happy to provide any other information you need.
  11. I have a registration and login option available on my site using php and mysql. When the username and password is authenticated I want it to open an app for the client and the app is dependent upon authentication from the website. I have seen a lot of diiferent forums but nothing really solid or up to date. Does anyone have any clue on how this can be done? fyi - this will be windows based and I am using PHP 5.0
×
×
  • 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.