Unstoppable Domains

Php adding to database

Spaceship Spaceship
Watch
Impact
11
im doing my first php coding here, (adding stuff to an admin panel of a script)

anyways, i've got it to add the stuff i type in the textboxes the database, but how do i make a certain field always the same (ie i want Affiliate to be added to the Type field every time i click submit)



Edit: sorry, forgot to finish the title. :P
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
I'm not exactly sure what you are asking for but i think it's this. You want to take information from a form field and add that information into a MySQL database. Doing that isn't hard.

First you have your table:
HTML:
<form method="post" action="where_this_page_should_go.php">

  <label>Your Name:

  <input type="text" name="name" />

  </label>

  <input name="submit" value="Submit" type="submit" />

</form>

then, in your PHP:
PHP:
if ( $_POST['submit'] ) {
	mysql_query("INSERT INTO table_name(name) VALUES('$name')") or die(mysql_error());
        echo 'success!';
}
 
0
•••
I dont know if I understand what you want :)

Add a hidden field named affilate in every page where do you want to useit.

Code:
<input type="hidden" name="affilate" value="<? echo $affilate;?>">

In this way the field affilate will be in every form you submit

Regards
 
0
•••
PHP:
elseif($_POST["mode"]=="new") {

		    $id = $_POST["id"];
		
			$title = $_POST["title"];

			$url = $_POST["url"];

			$redir_in = $_POST["redirs_in"];
	
			$redir_out = $_POST["redirs_out"];
			
			$type = affiliate;

			mysql_query("INSERT INTO redirs VALUES('id', '$url', '$title', '$type', '$redir_in', '$redir_out')");
			echo '<p>The link has been added successfully!</p>';

		}

Thats part of the code, but when i click submit instead of 'affiliate' added to the 'type' field, a '0' is added.



Edit: ok i fixed it.
 
Last edited:
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back