Jump to content

Recommended Posts

Hi all, I am having a ponder on how you would go about this:

 

Basically I have a page from where all the users in a database are shown, and you can access a page called userdetails.php by taking the id from the database ie userdetails.php?id=1

 

Once on this page I want to be able to add more details to various tables, so on this page I will have a various links for new forms eg.

 

add services

add prices

 

eg.

 

How would I make sure that in each form the id number matched the users id?

 

would i have to do something like addservices.php?id=$id ?

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/174164-how-to-define-id/
Share on other sites

Thanks,

 

now getting Notice: Undefined index: idaddservicesdo.php on line 6

 

Might be easier if just show you what I have!

 

addservices.php

 

<form method="post" action="addservicesdo.php">
<?php
if (isset($_GET['id'])) {
  echo "<input type='hidden' name='id' value='{$_GET['id']}' />";
}
?>
  <p>hosting package
    <select name="hosting">
      
      <option value="">None</option>
      <option value="standard">Standard</option>
      <option value="professional">Professional</option>
      <option value="business">Business</option>
    </select>
    
    <br>
    
    domain: 
    <input type="text" name="domain">
    <br>
    
    Backup plan 
    <select name="backup">
      <option value="">none</option>
      <option value="500mb">500mb</option>
      <option value="1000mb">1000mb</option>
      <option value="5000mb">5000mb</option>
      <option value="1000mb">1000mb</option>
    </select>
     <input type="submit" value="Next">
  </p>
</form>

 

addservicesdo.php

 

<?php

include('../include/dbconfig.php');
//let's start the session
session_start();
$id  = ($_POST['id']);
$hosting = ($_POST['hosting']); 
$domains = ($_POST['domain']);
$backup = ($_POST['backup']);


mysql_select_db("jolly_accounts", $conn);
$sql="INSERT INTO services (id,hosting,domains,backup) VALUES ('$id', '$hosting', '$domains', '$backup')"; 
if (!mysql_query($sql,$conn)) {
die('Error: ' . mysql_error());
}
echo "services successfully added to user.";
mysql_close($conn);
?>

 

So much for 'this will be easy!'

 

Thanks guys

 

Link to comment
https://forums.phpfreaks.com/topic/174164-how-to-define-id/#findComment-918123
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.