Jump to content

Migrating a script from one website to another


DRDTechAdmin

Recommended Posts

So a little background...

    Our old website uses a PHP script to collect information, set it in variables, and then compile this together and send an email with all the information to an email address we use for sales. Now... Everything works perfect on the old site, and I've moved every file I can think of to the new site.

 

The script runs fine, and I don't have any problems until we get to the very last step. the code is set up to (upon the click of a button) display the information that was entered, so as to allow the potential customer to print the quote request for their records, and then submit the data to us.

 

The problem comes in at this point. I step through this process using the view page source in Chrome, and when I click the button, it advances to the screen where it should show the data, but no data is displayed. No email is sent, either. When  I open two browsers and complete the process side by side, I get to the last bit and everything looks the same, except when I get to the area where the code is for these two actions (displaying and emailing)

 

On the new site, despite having the exact same files, there is no code that displays the collected information, and no email is sent. I have gone through everything I can think of, and it's extremely puzzling as to why this is the point where nothing works. Until I can get the ok to show the Code, I'm afraid I'm just asking for pointers and possible causes why it would work fine on the one site, but not on the other. I made sure to use the same folder names and locations as best I could. Is there anything I can do to further try and troubleshoot this? PHP is not my strongest language, so I'm hoping someone with some more experience can help point me in the right direction.

Edited by DRDTechAdmin
Link to comment
Share on other sites

php has/had (most have been removed) a number of short-cuts that are not portable between different php configurations.

 

most likely your code is depending on a setting (i won't mention its name since it has been removed and trying to turn it on would be an additional wasted of time) that magically set php variables from the form's $_POST data.

 

if the code is question doesn't have $_POST['the_form_field_name_here'] variables when trying to access the submitted form data, you need to change the php variables $the_form_field_name_here to use the corresponding $_POST variable. you can also just assign the $_POST ... variable to the php variable -

 

$the_form_field_name_here = $_POST['the_form_field_name_here']; // repeat for each form field

Link to comment
Share on other sites

Mac, I am looking through the code and I do see quite a bit of $_Post floating around quite a bit. Josh, I think you might have nailed it. I'm noticing that the code I fail to see that seems to do the magic, like pulling the variables to display them as Mac mentioned, the code to add the data to the email, and the Mail() function, are all under an if/else statement. I don't see a name for the DB, but the function I seem to be lacking for it to work is connect_to_db (); 

 

Time to look around for a Database!

Link to comment
Share on other sites

Okay... I found a folder in the same directory named database. I added that folder to the new site's directory, and ported the files over, but still no joy. Since the folders are in the same configuration, I take it that the actual path matters somewhere in the files?

 

Example

 

www.oldsite.com/html/database

www.oldsite.com/html/quote_request

 

www.newsite.com/httpdocs/database

www.newsite.com/httpdocs/quote_request

 

If this isn't it, I'm really going to have to get someone trustworthy and good to look at this PHP

Link to comment
Share on other sites

you need more than the php code/files that handle the database. You will need to setup the database itself with relevant table(s) and column(s). That isn't php code or files to copy over (though you could export the schema from your other server's database to make the process easier).

 

This is something you will need to do through a web admin interface like cpanel/phpmyadmin or on the server command line.

Link to comment
Share on other sites

The plot thickens! Well I'm aware we have a database/server here at the office, despite our websites being hosted on a third party server. I noticed on our old website server there is a phpMyAdmin application installed, I don't see that on the New Server. Could this be the culprit?!?

 

Sorry! I forgot to mention that phpMyAdmin says it's a tool to manage and automate Databases...

Edited by DRDTechAdmin
Link to comment
Share on other sites

well phpMyAdmin is just a convenient interface for interacting with the database; it's not the actual database. But the database the script was using on your old site is probably also on your old site's server.

 

Somewhere in your files should be config info for the database, for host, username, password and database name (and possibly table and column values as well). Sometimes it's coded separately in a "config" file. Sometimes people just pass the info directly to the php database connection function. If it's the latter, look at your php code that has the database stuff in it. You should see some sort of line involving connecting to the database. Something like mysql_connect, mysqli_connect, or maybe some sort of database class with "connect" somewhere in it.

 

Basically you're looking for the "host" value. If it's "localhost" then the database is located on the same server the php script ran on. If it's a remote location then that may be slightly better news for you. If it's pointing to your office's database/server then..well actually, if it's doing that and just dumping the files onto your new server didn't work, then probably your office's database/server needs to be configured to allow remote connection from your new site.

 

But back to "localhost" since it is very likely this - if this is the case then as mentioned, the database for your old site is setup on your old site's server, same as your script (more or less, but i'm trying to not needlessly complicate things). So you will need to go to your old site's database and at a minimum copy how it is setup, but on your new site. This is relatively easy with phpMyAdmin, but it sounds like you don't have it on your new server. Or else you do and you haven't found it. In any case..yeah since this is all new to you, I would not really recommend poking at it yourself.

 

Alternatively.. if for now you don't care about the stuff being stored in the database (and you're sure some other script doesn't depend on it), you could always strip out the part of your script that involves database interaction. Remove all that stuff, including the condition your mail functions are wrapped in. That way your script will mail the stuff out at least (well, assuming the mail server is configured properly!).

Link to comment
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.